| 17. The rest |
| Namespace 0.6:: |
Pike 0.6 compatibility.
The symbols in this namespace will appear in programs that use #pike 0.6 or lower.
7.0::
inherit 7.0:: :
array(mixed) aggregate(mixed ... args)
More lax types than in later versions.
| Module Array |
inherit Array : Array
array map(array x, int|string|function fun, mixed ... args)
Much simplified type compared to later versions of map.
| Namespace 7.6:: |
Pike 7.6 compatibility.
The symbols in this namespace will appear in programs that use #pike 7.6 or lower.
inherit predef:: :
| Module Stdio |
inherit Stdio.module : module
string read_file(string filename)
string read_file(string filename, int start, int len)
Read len lines from a file filename after skipping start lines and return those lines as a string. If both start and len are omitted the whole file is read.
read_bytes() , write_file()
string read_bytes(string filename, int start, int len)
string read_bytes(string filename, int start)
string read_bytes(string filename)
Read len number of bytes from the file filename starting at byte start , and return it as a string.
If len is omitted, the rest of the file will be returned.
If start is also omitted, the entire file will be returned.
Throws an error if filename isn't a regular file.
Returns 0 (zero) on failure to open filename .
Returns a string with the requested data otherwise.
read_file , write_file() , append_file()
int write_file(string filename, string str, int|void access)
Write the string str onto the file filename . Any existing data in the file is overwritten.
For a description of access , see Stdio.File()->open() .
Throws an error if filename couldn't be opened for writing.
Returns the number of bytes written.
append_file() , read_bytes() , Stdio.File()->open()
int append_file(string filename, string str, int|void access)
Append the string str onto the file filename .
For a description of access , see Stdio.File->open() .
Throws an error if filename couldn't be opened for writing.
Returns the number of bytes written.
write_file() , read_bytes() , Stdio.File()->open()
| Module Standards |
| Module Standards.UUID |
string new()
Return a new binary UUID.
string new_string()
Return a new UUID string.
| Module Calendar |
| Module Calendar.ISO |
This is the standard western calendar, which is a derivate of the Gregorian calendar, but with weeks that starts on Monday instead of Sunday.
inherit Calendar.Gregorian : Gregorian
| Module Calendar.YMD |
base for all Roman-kind of Calendars, ie, one with years, months, weeks and days
| CLASS Calendar.YMD.YMD |
Base (virtual) time period of the Roman-kind of calendar.
string format_iso_ymd()
string format_ymd()
string format_ymd_short()
string format_ymd_xshort()
string format_iso_week()
string format_iso_week_short()
string format_week()
string format_week_short()
string format_month()
string format_month_short()
string format_iso_time()
string format_time()
string format_time_short()
string format_time_xshort()
string format_mtime()
string format_xtime()
string format_tod()
string format_todz()
string format_xtod()
string format_mod()
Format the object into nice strings;
iso_ymd "2000-06-02 (Jun) -W22-5 (Fri)" [2]
ext_ymd "Friday, 2 June 2000" [2]
ymd "2000-06-02"
ymd_short "20000602"
ymd_xshort "000602" [1]
iso_week "2000-W22"
iso_week_short "2000W22"
week "2000-w22" [2]
week_short "2000w22" [2]
month "2000-06"
month_short "200006" [1]
iso_time "2000-06-02 (Jun) -W22-5 (Fri) 00:00:00 UTC+1" [2]
ext_time "Friday, 2 June 2000, 00:00:00" [2]
ctime "Fri Jun 2 00:00:00 2000\n" [2] [3]
http "Fri, 02 Jun 2000 00:00:00 GMT" [4]
time "2000-06-02 00:00:00"
time_short "20000602 00:00:00"
time_xshort "000602 00:00:00"
iso_short "2000-06-02T00:00:00"
mtime "2000-06-02 00:00"
xtime "2000-06-02 00:00:00.000000"
tod "00:00:00"
tod_short "000000"
todz "00:00:00 CET"
todz_iso "00:00:00 UTC+1"
xtod "00:00:00.000000"
mod "00:00"
[1] note conflict (think 1 February 2003)
[2] language dependent
[3] as from the libc function ctime()
[4] as specified by the HTTP standard;
not language dependent.
float fraction_no()
int hour_no()
int julian_day()
int leap_year()
int minute_no()
int month_day()
int month_no()
int second_no()
int utc_offset()
int week_day()
int week_no()
int year_day()
int year_no()
string month_name()
string month_shortname()
string month_day_name()
string week_day_name()
string week_day_shortname()
string week_name()
string year_name()
string tzname()
string tzname_iso()
function method int unix_time()
Returns the unix time integer corresponding to the start
of the time range object. (An unix time integer is UTC.)
function method datetime()
This gives back a mapping with the relevant
time information (representing the start of the period);
([ "year": int // year number (2000 AD=2000, 1 BC==0)
"month": int(1..) // month of year
"day": int(1..) // day of month
"yearday": int(0..) // day of year
"week": int(1..) // week of year
"week_day": int(0..) // day of week
"timezone": int // offset to utc, including dst
"unix": int // unix time
"julian": int // julian day
// for compatibility:
"hour": 0 // hour of day, including dst
"minute": 0 // minute of hour
"second": 0 // second of minute
"fraction": 0.0 // fraction of second
]);
Day of week is compatible with old versions, ie, 0 is sunday, 6 is saturday, so it shouldn't be used to calculate the day of the week with the given week number. Year day is also backwards compatible, ie, one (1) less then from the year_day() function.
Second second()
Second second(int n)
Minute minute(int hour, int minute, int second)
array(Second) seconds()
array(Second) seconds(int first, int last)
int number_of_seconds()
Minute minute()
Minute minute(int n)
Minute minute(int hour, int minute)
array(Minute) minutes()
array(Minute) minutes(int first, int last)
int number_of_minutes()
Hour hour()
Hour hour(int n)
array(Hour) hours()
array(Hour) hours(int first, int last)
int number_of_hours()
| CLASS Calendar.YMD.Year |
This is the time period of a year.
void Calendar.YMD.Year("unix", int unix_time)
void Calendar.YMD.Year("julian", int|float julian_day)
void Calendar.YMD.Year(int year)
void Calendar.YMD.Year(string year)
void Calendar.YMD.Year(TimeRange range)
It's possible to create the standard year by using three different methods; either the normal way - from standard unix time or the julian day, and also, for more practical use, from the year number.
Month month()
Month month(int n)
Month month(string name)
The Year type overloads the month() method, so it is possible to get a specified month by string:
year->month("April")
The integer and no argument behavior is inherited from YMD ().
Week week()
Week week(int n)
Week week(string name)
The Year type overloads the week() method, so it is possible to get a specified week by name:
year->week("17") year->week("w17")
The integer and no argument behavior is inherited from YMD ().
This is useful, since the first week of a year not always (about half the years, in the ISO calendar) is numbered '1'.
| CLASS Calendar.YMD.Week |
The Calendar week represents a standard time period of a week. In the Gregorian calendar, the standard week starts on a sunday and ends on a saturday; in the ISO calendar, it starts on a monday and ends on a sunday.
The week are might not be aligned to the year, and thus the week may cross year borders and the year of the week might not be the same as the year of all the days in the week. The basic rule is that the week year is the year that has the most days in the week, but since week number only is specified in the ISO calendar - and derivates - the week number of most calendars is the week number of most of the days in the ISO calendar, which modifies this rule for the Gregorian calendar; the week number and year is the same as for the ISO calendar, except for the sundays.
When adding, moving and subtracting months to a week, it falls back to using days.
When adding, moving or subtracting years, if tries to place the moved week in the resulting year.
void Calendar.YMD.Week("unix", int unix_time)
void Calendar.YMD.Week("julian", int|float julian_day)
void Calendar.YMD.Week(int year, int week)
It's possible to create the standard week by using three different methods; either the normal way - from standard unix time or the julian day, and also, for more practical use, from year and week number.
void Calendar.YMD.Week("unix", int unix_time)
void Calendar.YMD.Week("julian", int|float julian_day)
void Calendar.YMD.Week(int year, int month, int day)
void Calendar.YMD.Week(int year, int year_day)
void Calendar.YMD.Week(int julian_day)
It's possible to create the day by using five different methods; either the normal way - from standard unix time or the julian day, and also, for more practical use, from year, month and day, from year and day of year, and from julian day without extra fuzz.
Day day()
Day day(int n)
Day day(string name)
The Week type overloads the day() method, so it is possible to get a specified weekday by string:
week->day("sunday")
The integer and no argument behavior is inherited from YMD ().
the weekday-from-string routine is language dependent.
| CLASS Calendar.YMD.Hour |
global convinience functions
TimeRange parse(string fmt, string arg)
parse a date, create relevant object
fmt is in the format "abc%xdef..."
where abc and def is matched, and %x is
one of those time units:
%Y absolute year
%y dwim year (70-99 is 1970-1999, 0-69 is 2000-2069)
%M month (number, name or short name) (needs %y)
%W week (needs %y)
%D date (needs %y, %m)
%d short date (20000304, 000304)
%a day (needs %y)
%e weekday (needs %y, %w)
%h hour (needs %d, %D or %W)
%m minute (needs %h)
%s second (needs %m)
%S seconds since the Epoch (only combines with %f)
%f fraction of a second (needs %s or %S)
%t short time (205314, 2053)
%z zone
%p "am" or "pm"
%n empty string (to be put at the end of formats)
0 if format doesn't match data, or the appropriate time object.
The zone will be a guess if it doesn't state an exact regional timezone (like "Europe/Stockholm") - most zone abbriviations (like "CET") are used by more then one region with it's own daylight saving rules. Also beware that for instance CST can be up to four different zones, central Australia or America being the most common.
Abbreviation Interpretation
AMT America/Manaus [UTC-4]
AST America/Curacao [UTC-4]
CDT America/Costa_Rica [UTC-6]
CST America/El Salvador [UTC-6]
EST America/Panama [UTC-5]
GST Asia/Dubai [UTC+4]
IST Asia/Jerusalem [UTC+2]
WST Australia/Perth [UTC+8]
This mapping is modifiable in the ruleset, see
Ruleset.set_abbr2zone .
function Day dwim_day(string date)
function Day dwim_day(string date,TimeRange context)
Tries a number of different formats on the given date (in order):
parse format as in
"%y-%M-%D (%M) -W%W-%e (%e)" "2000-03-20 (Mar) -W12-1 (Mon)"
"%y-%M-%D" "2000-03-20", "00-03-20"
"%M%/%D/%y" "3/20/2000"
"%D%*[ /]%M%*[ /-,]%y" "20/3/2000" "20 mar 2000" "20/3 -00"
"%e%*[ ]%D%*[ /]%M%*[ /-,]%y" "Mon 20 Mar 2000" "Mon 20/3 2000"
"-%y%*[ /]%D%*[ /]%M" "-00 20/3" "-00 20 mar"
"-%y%*[ /]%M%*[ /]%D" "-00 3/20" "-00 march 20"
"%y%*[ /]%D%*[ /]%M" "00 20 mar" "2000 20/3"
"%y%*[ /]%M%*[ /]%D" "2000 march 20"
"%D%.%M.%y" "20.3.2000"
"%D%*[ -/]%M" "20/3" "20 mar" "20-03"
"%M%*[ -/]%D" "3/20" "march 20"
"%M-%D-%y" "03-20-2000"
"%D-%M-%y" "20-03-2000"
"%e%*[- /]%D%*[- /]%M" "mon 20 march"
"%e%*[- /]%M%*[- /]%D" "mon/march/20"
"%e%*[ -/wv]%W%*[ -/]%y" "mon w12 -00" "1 w12 2000"
"%e%*[ -/wv]%W" "mon w12"
"%d" "20000320", "000320"
"today" "today"
"last %e" "last monday"
"next %e" "next monday"
Casts exception if it fails to dwim out a day. "dwim" means do-what-i-mean.
function datetime(int|void unix_time)
Replacement for localtime; gives back a mapping:
([ "year": int // year number (2000 AD=2000, 1 BC==0)
"month": int(1..) // month of year
"day": int(1..) // day of month
"yearday": int(1..) // day of year
"week": int(1..) // week of year
"week_day": int(1..) // day of week (depending on calendar)
"unix": int // unix time
"julian": float // julian day
"hour": int(0..) // hour of day, including dst
"minute": int(0..59) // minute of hour
"second": int(0..59) // second of minute
"fraction": float // fraction of second
"timezone": int // offset to utc, including dst
]);
This is the same as calling Second ()->datetime ().
function datetime_name(int|void unix_time) function datetime_short_name(int|void unix_time) Compat functions; same as format_iso and format_iso_short .
function string format_iso(void|int unix_time)
function string format_iso_short(void|int unix_time)
function string format_iso_tod(void|int unix_time)
function string format_day_iso(void|int unix_time)
function string format_day_iso_short(void|int unix_time)
Format the object into nice strings;
iso "2000-06-02 (Jun) -W22-5 (Fri) 11:57:18 CEST"
iso_short "2000-06-02 11:57:18"
iso_tod "11:57:18"
| Module Calendar.Gregorian |
This is the standard conservative christian calendar, used regularly in some countries - USA, for instance - and which derivate - the ISO calendar - is used in most of Europe.
inherit Calendar.YMD : YMD
| Module Debug |
array(array(int|string)) describe_program(program p)
Debug function for showing the symbol table of a program.
| Module Image |
| CLASS Image.Image |
inherit Image.Image : Image
array(Image.Color) select_colors(int n)
Do (array)Image.Colortable(this, n) instead.
Image.Image map_closest(array(array(int)) t)
Do Image.Colortable(t)->map(this) instead.
Image.Image map_fast(array(array(int)) t)
Do Image.Colortable(t)->map(this) instead.
Image.Image map_fs(array(array(int)) t)
Do
Image.Colortable(t)->floyd_steinberg()->map(this)
instead.
| Module Protocols |
| Module Protocols.TELNET |
Pike 7.6 compatibility.
Some symbols in Protocols.TELNET that now are protected used to be visible in Pike 7.6 and earlier.
inherit Protocols.TELNET : TELNET
inherit predef::Protocols.TELNET : TELNET
Based on the current Protocols.TELNET.
| CLASS Protocols.TELNET.protocol |
Pike 7.6 compatibility version of Protocols.TELNET.protocol.
inherit TELNET::protocol : protocol
Based on the current Protocols.TELNET.protocol.
void Protocols.TELNET.protocol(object f, function(mixed:void) r_cb, function(mixed|void:string) w_cb, function(mixed|void:void) c_cb, mapping callbacks, mixed|void new_id)
create() used to be visible.
::create()
void setup()
setup() used to be visible.
::setup()
| CLASS Protocols.TELNET.LineMode |
Pike 7.6 compatibility version of Protocols.TELNET.LineMode.
inherit TELNET::LineMode : LineMode
Based on the current Protocols.TELNET.LineMode.
void Protocols.TELNET.LineMode(object f, function(mixed:void) r_cb, function(mixed|void:string) w_cb, function(mixed|void:void) c_cb, mapping callbacks, mixed|void new_id)
create() used to be visible.
::create()
void setup()
setup() used to be visible.
::setup()
| CLASS Protocols.TELNET.Readline |
Pike 7.6 compatibility version of Protocols.TELNET.Readline.
inherit TELNET::Readline : Readline
Based on the current Protocols.TELNET.Readline.
void Protocols.TELNET.Readline(object f, function(mixed:void) r_cb, function(mixed|void:string) w_cb, function(mixed|void:void) c_cb, mapping callbacks, mixed|void new_id)
create() used to be visible.
::create()
void setup()
setup() used to be visible.
::setup()
| Namespace 7.4:: |
Pike 7.4 compatibility.
The symbols in this namespace will appear in programs that use #pike 7.4 or lower.
inherit 7.6:: :
array(int) rusage()
Return resource usage. An error is thrown if it isn't supported or if the system fails to return any information.
Returns an array of ints describing how much resources the interpreter process has used so far. This array will have at least 29 elements, of which those values not available on this system will be zero.
The elements are as follows:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The values will not be further explained here; read your system manual for more information.
All values may not be present on all systems.
time() , System.getrusage()
int hash(string s)
int hash(string s, int max)
Return an integer derived from the string s . The same string will always hash to the same value, also between processes.
If max is given, the result will be >= 0 and < max , otherwise the result will be >= 0 and <= 0x7fffffff.
This function is provided for backward compatibility reasons.
This function is byte-order dependant for wide strings.
hash() , 7.0::hash()
| Module Stdio |
| CLASS Stdio.File |
The life length of the Fd instance has changed. In newer versions it's always the same as for the File instance. That can theoretically cause incompatibilities in code that uses File.dup and File.assign, which are deprecated and very rarely used.
inherit Stdio.File : File
| Module Standards |
| Module Standards.ASN1 |
| Module Standards.ASN1.Encode |
This module is obsolete. All code should use ASN1.Types instead.
| Module Standards.PKCS |
| Module Standards.PKCS.Signature |
inherit Standards.PKCS.Signature : Signature
string build_digestinfo(string msg, object hash)
In Pike 7.6 the hash is required to be a Crypto.Hash object.
| Module Crypto |
string crypt_md5(string pw, void|string salt)
From Pike 7.5 pw and salt are binary strings, so
the result is different if any of these includes "\0".
The return type is also changed from string to int|string. If the second argument is a hash, pw will be hashed with the salt from the hash and compared with the hash.
constant Crypto.string_to_hex
constant Crypto.hex_to_string
string des_parity(string s)
des_parity is removed. Instead there is Crypto.DES->fix_parity , but it always outputs a key sized string.
| CLASS Crypto.md4 |
inherit Nettle.MD4_State : MD4_State
| CLASS Crypto.idea_cbc |
Use Crypto.CBC(Crypto.IDEA) instead.
inherit Nettle.CBC : CBC
| CLASS Crypto.idea |
inherit Nettle.IDEA_State : IDEA_State
| CLASS Crypto.sha |
inherit Nettle.SHA1_State : SHA1_State
| CLASS Crypto.md5 |
inherit Nettle.MD5_State : MD5_State
| CLASS Crypto.cast |
inherit Nettle.CAST128_State : CAST128_State
| CLASS Crypto.des |
inherit Nettle.DES_State : DES_State
| CLASS Crypto.crypto |
inherit Nettle.Proxy : Proxy
| CLASS Crypto.des3 |
inherit Nettle.DES3_State : DES3_State
| CLASS Crypto.cbc |
inherit Nettle.CBC : CBC
| CLASS Crypto.des_cbc |
Use Crypto.CBC(Crypto.DES) instead.
inherit Nettle.CBC : CBC
| CLASS Crypto.invert |
Inversion crypto module.
string name()
Returns the string "INVERT".
int(8..8) query_block_size()
Returns the block size for the invert crypto (currently 8).
int(0..0) query_key_length()
Returns the minimum key length for the invert crypto.
Since this crypto doesn't use a key, this will be 0.
void set_encrypt_key(string key)
Set the encryption key (currently a no op).
void set_decrypt_key(string key)
Set the decryption key (currently a no op).
string crypt_block(string data)
De/encrypt the string data with the invert crypto (ie invert the string).
| CLASS Crypto.md2 |
inherit Nettle.MD2_State : MD2_State
| CLASS Crypto.substitution |
inherit Crypto.Substitution : Substitution
| CLASS Crypto.rijndael |
inherit Nettle.AES_State : AES_State
| CLASS Crypto.dsa |
| CLASS Crypto.rsa |
inherit Crypto.RSA : RSA
| CLASS Crypto.hmac |
inherit Crypto.HMAC : HMAC
| CLASS Crypto.des3_cbc |
Use Crypto.CBC(Crypto.DES3) instead.
inherit Nettle.CBC : CBC
| CLASS Crypto.arcfour |
inherit Nettle.ARCFOUR_State : ARCFOUR_State
| CLASS Crypto.aes |
inherit Nettle.AES_State : AES_State
| Module Crypto.koremutake |
inherit Crypto.Koremutake : Koremutake
| Module Crypto.randomness |
Assorted stronger or weaker randomnumber generators. These devices try to collect entropy from the environment. They differ in behaviour when they run low on entropy, /dev/random will block if it can't provide enough random bits, while /dev/urandom will degenerate into a reasonably strong pseudo random generator
string some_entropy()
Executes several programs (last -256, arp -a, netstat -anv, netstat -mv, netstat -sv, uptime, ps -fel, ps aux, vmstat -s, vmstat -M, iostat, iostat -cdDItx) to generate some entropy from their output. On Microsoft Windows the Windows cryptographic routines are called to generate random data.
RandomSource reasonably_random()
Returns a reasonably random random-source.
RandomSource really_random(int|void may_block)
Returns a really random random-source.
| CLASS Crypto.randomness.RandomSource |
Virtual class for randomness source object.
string read(int(0..) len)
Returns a string of length len with (pseudo) random values.
| CLASS Crypto.randomness.arcfour_random |
A pseudo random generator based on the arcfour crypto.
inherit Nettle.ARCFOUR_State : ARCFOUR_State
void Crypto.randomness.arcfour_random(string secret)
Initialize and seed the arcfour random generator.
string read(int len)
Return a string of the next len random characters from the arcfour random generator.
| Module Sql |
| CLASS Sql.sql |
inherit Sql.Sql : Sql
| Module Locale |
| Module Locale.Charset |
inherit Locale.Charset : Charset
constant Locale.Charset._encoder
| CLASS Locale.Charset.ascii |
This class does not exist in the Locale module in Pike 7.6.
| Module ADT |
| CLASS ADT.Heap |
inherit ADT.Heap : Heap
mixed top()
This method has been renamed to pop in Pike 7.6.
| Module Protocols |
| Module Protocols.SMTP |
| CLASS Protocols.SMTP.protocol |
inherit Protocols.SMTP.Protocol : Protocol
| CLASS Protocols.SMTP.client |
inherit Protocols.SMTP.Client : Client
| Module SSL |
| CLASS SSL.cipher |
Encryption and MAC algorithms used in SSL.
inherit "constants"
| CLASS SSL.sslfile |
Interface similar to Stdio.File.
inherit "cipher"
inherit SSL.connection : connection
| CLASS SSL.constants |
Protocol constants
| Module Array |
inherit Array : Array
array(array(array)) diff3_old(array mid, array left, array right)
This diff3 implementation is obsoleted by Array.diff3 .
| Module Thread |
inherit Thread : Thread
constant Thread.Mutex
The Mutex destruct behaviour in Pike 7.4 and below is different from 7.6 in that destructing a mutex destroys the key that is locking it.
| Namespace 7.0:: |
Pike 7.0 compatibility.
The symbols in this namespace will appear in programs that use #pike 7.0 or lower.
7.2::
inherit 7.2:: :
array(int) file_stat(string path, void|int symlink)
Stat a file (Pike 7.0 compatibility).
Returns an array with the following content:
| ||||||||||||||||
See predef::file_stat() for a full description of the array.
predef::file_stat()
string _typeof(mixed x)
Get the runtime type of a value (Pike 7.0 compatibility).
Returns the type of x as a string.
predef::_typeof()
mapping m_delete(mapping m, mixed x)
Delete an entry x from a mapping m (Pike 7.0 compatibility).
Returns m .
predef::m_delete()
int hash(string s, int|void f)
Calculate a hash of a string (Pike 7.0 compatibility).
This function is now available as predef::hash_7_0() .
predef::hash_7_0() , predef::hash()
int hash(string s)
int hash(string s, int max)
Return an integer derived from the string s . The same string always hashes to the same value, also between processes.
If max is given, the result will be >= 0 and < max , otherwise the result will be >= 0 and <= 0x7fffffff.
This function is provided for backward compatibility reasons.
This function is not NUL-safe, and is byte-order dependant.
hash() , 7.4::hash()
| Module Calendar |
This module implements calendar calculations, and base classes for time units.
This module exists only for backward compatibility with Pike 7.0.
| CLASS Calendar._TimeUnit |
Base class for units of time.
array(string) lesser()
Gives a list of methods to get lesser (shorter) time units.
ie, for a month, this gives back ({"day"})
and the method day(mixed n) gives back that
day object. The method days() gives back a
list of possible argument values to the method day.
Concurrently, Array.map(o->days(),o->day) gives
a list of day objects in the object o.
Ie:
array(string) lesser() - gives back a list of possible xxx's.
object xxxs() - gives back a list of possible n's.
object xxx(mixed n) - gives back xxx n
object xxx(object(Xxx) o) - gives back the corresponing xxx
The list of n's (as returned from xxxs) are always in order.
There are two n's with special meaning, 0 and -1. 0 always gives the first xxx, equal to my_obj->xxx(my_obj->xxxs()[0]), and -1 gives the last, equal to my_obj->xxx(my_obj->xxxs()[-1]).
To get all xxxs in the object, do something like
Array.map(my_obj->xxxs(),my_obj->xxx).
xxx(object) may return zero, if there was no correspondning xxx.
array(string) greater()
Gives a list of methods to get greater (longer) time units
from this object. For a month, this gives back ({"year"}),
thus the method month->year() gives the year object.
object next()
object prev()
object `+(int n)
object `-(int n)
object `-(object x)
next() and prev() give the logical next and previous object.
The `+() operator gives that logical relative object,
ie my_day+14 gives 14 days ahead.
`-() works the same way, but can also take an object
of the same type and give the difference as an integer.
| Module Calendar.Gregorian |
time units: <ref>Year</ref>, <ref>Month</ref>, <ref>Week</ref>, <ref>Day</ref>
object parse(string fmt, string arg)
parse a date, create relevant object fmt is in the format "abc%xdef..." where abc and def is matched, and %x is one of those time units: %Y absolute year %y year (70-99 is 1970-1999, 0-69 is 2000-2069) %M month (number, name or short name) (needs %y) %W week (needs %y) %D date (needs %y, %m) %a day (needs %y) %e weekday (needs %y, %w) %h hour (needs %d, %D or %W) %m minute (needs %h) %s second (needs %s)
mapping(string:int) datetime(int|void unix_time, int|void skip_extra)
Replacement for localtime() .
string datetime_name(int|void unix_time)
Replacement for ctime() .
string datetime_short_name(int|void unix_time)
Replacement for ctime.
| CLASS Calendar.Gregorian.Year |
A Calendar._TimeUnit .
Lesser units: <ref>Month</ref>, <ref>Week</ref>, <ref>Day</ref> Greater units: none
inherit _TimeUnit : _TimeUnit
| Module Calendar.Stardate |
time unit: TNGDate
| CLASS Calendar.Stardate.TNGDate |
Implements ST:TNG stardates. Can be used as create argument to Day.
inherit Calendar._TimeUnit : _TimeUnit
| Namespace predef:: |
constant TOKENIZE_KEEP_ESCAPES
Don't unquote backslash-sequences in quoted strings during tokenizing. This is used for bug-compatibility with Microsoft...
tokenize() , tokenize_labled()
void (array(string) headers, object from, int offset, int len, array(string) trailers, object to, function callback, mixed ... args)
Low-level implementation of Stdio.sendfile() .
Sends headers followed by len bytes starting at offset from the file from followed by trailers to the file to . When completed callback will be called with the total number of bytes sent as the first argument, followed by args .
Any of headers , from and trailers may be left out
by setting them to 0.
Setting offset to -1 means send from the current position in
from .
Setting len to -1 means send until from 's end of file is
reached.
Don't use this class directly! Use Stdio.sendfile() instead.
In Pike 7.7 and later the callback function will be called from the backend associated with to .
Stdio.sendfile()
array(string) listxattr(string file, void|int(0..1) symlink)
Return an array of all extended attributes set on the file
string getxattr(string file, string attr, void|int(0..1) symlink)
Return the value of a specified attribute, or 0 if it does not exist.
void removexattr(string file, string attr, void|int(0..1) symlink)
Remove the specified extended attribute.
void setxattr(string file, string attr, string value, int flags, void|int(0..1) symlink)
Set the attribute attr to the value value .
The flags parameter can be used to refine the semantics of the operation.
Stdio.XATTR_CREATE specifies a pure create, which fails if the named attribute exists already.
Stdio.XATTR_REPLACE specifies a pure replace operation, which fails if the named attribute does not already exist.
By default (no flags), the extended attribute will be created if need be, or will simply replace the value if the attribute exists.
1 if successful, 0 otherwise, setting errno.
Stdio.Stat file_stat(string path, void|int(0..1) symlink)
Stat a file.
If the argument symlink is 1 symlinks will not be followed.
If the path specified by path doesn't exist 0 (zero) will
be returned.
Otherwise an object describing the properties of path will be returned.
In Pike 7.0 and earlier this function returned an array with 7 elements. The old behaviour can be simulated with the following function:
array(int) file_stat(string path, void|int(0..1) symlink)
{
File.Stat st = predef::file_stat(path, symlink);
if (!st) return 0;
return (array(int))st;
}
Stdio.Stat , Stdio.File->stat()
int file_truncate(string file, int length)
Truncates the file file to the length specified in length .
Returns 1 if ok, 0 if failed.
mapping(string:int) filesystem_stat(string path)
Returns a mapping describing the properties of the filesystem containing the path specified by path .
If a filesystem cannot be determined 0 (zero) will be returned.
Otherwise a mapping(string:int) with the following fields will be returned:
|
Please note that not all members are present on all OSs.
file_stat()
int rm(string f)
Remove a file or directory.
Returns 0 (zero) on failure, 1 otherwise.
mkdir() , Stdio.recursive_rm()
int mkdir(string dirname, void|int mode)
Create a directory.
If mode is specified, it's will be used for the new directory after
being &'ed with the current umask (on OS'es that support this).
Returns 0 (zero) on failure, 1 otherwise.
rm() , cd() , Stdio.mkdirhier()
array(string) get_dir(void|string dirname)
Returns an array of all filenames in the directory dirname , or
0 (zero) if the directory does not exist. When no
dirname is given, current work directory is used.
mkdir() , cd()
int cd(string s)
Change the current directory for the whole Pike process.
Returns 1 for success, 0 (zero) otherwise.
getcwd()
string getcwd()
Returns the current working directory.
cd()
int exece(string file, array(string) args)
int exece(string file, array(string) args, mapping(string:string) env)
This function transforms the Pike process into a process running the program specified in the argument file with the arguments args .
If the mapping env is present, it will completely replace all environment variables before the new program is executed.
This function only returns if something went wrong during exece(2),
and in that case it returns 0 (zero).
The Pike driver _dies_ when this function is called. You must either use fork() or Process.create_process() if you wish to execute a program and still run the Pike runtime.
This function is not available on all platforms.
Process.create_process() , fork() , Stdio.File->pipe()
int mv(string from, string to)
Rename or move a file or directory.
If the destination already exists, it will be replaced. Replacement often only works if to is of the same type as from , i.e. a file can only be replaced by another file and so on. Also, a directory will commonly be replaced only if it's empty.
On some OSs this function can't move directories, only rename them.
Returns 0 (zero) on failure, 1 otherwise. Call
errno() to get more error info on failure.
rm()
string strerror(int errno)
This function returns a description of an error code. The error code is usually obtained from eg Stdio.File->errno() .
On some platforms the string returned can be somewhat nondescriptive.
int errno()
This function returns the system error from the last file operation.
Note that you should normally use Stdio.File->errno() instead.
Stdio.File->errno() , strerror()
float sin(float f)
Returns the sine value for f . f should be specified in radians.
asin() , cos() , tan()
float asin(float f)
Return the arcus sine value for f . The result will be in radians.
sin() , acos()
float cos(float f)
Return the cosine value for f . f should be specified in radians.
acos() , sin() , tan()
float acos(float f)
Return the arcus cosine value for f . The result will be in radians.
cos() , asin()
float tan(float f)
Returns the tangent value for f . f should be specified in radians.
atan() , sin() , cos()
float atan(float f)
Returns the arcus tangent value for f . The result will be in radians.
tan() , asin() , acos() , atan2()
float atan2(float f1, float f2)
Returns the arcus tangent value for f1 /f2 , and uses the signs of f1 and f2 to determine the quadrant. The result will be in radians.
tan() , asin() , acos() , atan()
float sinh(float f)
Returns the hyperbolic sine value for f .
asinh() , cosh() , tanh()
float asinh(float f)
Return the hyperbolic arcus sine value for f .
sinh() , acosh()
float cosh(float f)
Return the hyperbolic cosine value for f .
acosh() , sinh() , tanh()
float acosh(float f)
Return the hyperbolic arcus cosine value for f .
cosh() , asinh()
float tanh(float f)
Returns the hyperbolic tangent value for f .
atanh() , sinh() , cosh()
float atanh(float f)
Returns the hyperbolic arcus tangent value for f .
tanh() , asinh() , acosh()
float sqrt(float f)
int sqrt(int i)
mixed sqrt(object o)
Returns the square root of f , or in the integer case, the square root truncated to the closest lower integer. If the argument is an object, the lfun _sqrt in the object will be called.
pow() , log() , exp() , floor() , lfun::_sqrt
float log(float f)
Return the natural logarithm of f .
exp( log(x) ) == x for x > 0.
pow() , exp()
float exp(float|int f)
Return the natural exponential of f .
log( exp( x ) ) == x as long as exp(x) doesn't overflow an int.
pow() , log()
int|float pow(float|int n, float|int x)
mixed pow(object n, float|int|object x)
Return n raised to the power of x . If both n and x are integers the result will be an integer. If n is an object its pow method will be called with x as argument.
exp() , log()
float floor(float f)
Return the closest integer value less or equal to f .
floor() does not return an int, merely an integer value
stored in a float.
ceil() , round()
float ceil(float f)
Return the closest integer value greater or equal to f .
ceil() does not return an int, merely an integer value
stored in a float.
floor() , round()
float round(float f)
Return the closest integer value to f .
round() does not return an int, merely an integer value
stored in a float.
floor() , ceil()
int|float|object limit(int|float|object minval, int|float|object x, int|float|object maxval)
Limits the value x so that it's between minval and maxval . If x is an object, it must implement the lfun::`< method.
max() and min()
int|float|object min(int|float|object ... args)
string min(string ... args)
int(0..0) min()
Returns the smallest value among args . Compared objects must implement the lfun::`< method.
max() and limit()
int|float|object max(int|float|object ... args)
string max(string ... args)
int(0..0) max()
Returns the largest value among args . Compared objects must implement the lfun::`< method.
min() and limit()
float abs(float f)
int abs(int f)
object abs(object f)
Return the absolute value for f . If f is an object it must implement lfun::`< and unary lfun::`- .
int sgn(mixed value)
int sgn(mixed value, mixed zero)
Check the sign of a value.
Returns -1 if value is less than zero ,
1 if value is greater than zero and 0
(zero) otherwise.
abs()
array(array(string)|string) tokenize(string code)
Tokenize a string of C tokens.
Returns an array with C-level tokens and the remainder (a partial token), if any.
array(array(string)|string) tokenize(string code)
Tokenize a string of Pike tokens.
Returns an array with Pike-level tokens and the remainder (a partial token), if any.
string sprintf(string format, mixed ... args)
Print formated output to string.
The format string is a string containing a description of how to output the data in args . This string should generally speaking have one %<modifiers><operator> format specifier (examples: %s, %0d, %-=20s) for each of the arguments.
The following modifiers are supported:
|
The following operators are supported:
|
Most modifiers and operators are combinable in any fashion, but some combinations may render strange results.
If an argument is an object that implements lfun::_sprintf() , that callback will be called with the operator as the first argument, and the current modifiers as the second. The callback is expected to return a string.
Pike v7.4 release 13 running Hilfe v3.5 (Incremental Pike Frontend) > sprintf("The unicode character %c has character code %04X.", 'A', 'A'); (1) Result: "The unicode character A has character code 0041." > sprintf("#%@02X is the HTML code for purple.", Image.Color.purple->rgb()); (2) Result: "#A020F0 is the HTML code for purple." > int n=4711; > sprintf("%d = hexadecimal %x = octal %o = %b binary", n, n, n, n); (3) Result: "4711 = hexadecimal 1267 = octal 11147 = 1001001100111 binary"
sprintf style formatting is applied by many formatting functions, such write() and werror .
The 'q' operator was added in Pike 7.7.
> write(#"Formatting examples: Left adjusted [%-10d] Centered [%|10d] Right adjusted [%10d] Zero padded [%010d] ", n, n, n, n); Formatting examples: Left adjusted [4711 ] Centered [ 4711 ] Right adjusted [ 4711] Zero padded [0000004711] (5) Result: 142 int screen_width=70; > write("%-=*s\n", screen_width, >> "This will wordwrap the specified string within the "+ >> "specified field size, this is useful say, if you let "+ >> "users specify their screen size, then the room "+ >> "descriptions will automagically word-wrap as appropriate.\n"+ >> "slosh-n's will of course force a new-line when needed.\n"); This will wordwrap the specified string within the specified field size, this is useful say, if you let users specify their screen size, then the room descriptions will automagically word-wrap as appropriate. slosh-n's will of course force a new-line when needed. (6) Result: 355 > write("%-=*s %-=*s\n", screen_width/2, >> "Two columns next to each other (any number of columns will "+ >> "of course work) independantly word-wrapped, can be useful.", >> screen_width/2-1, >> "The - is to specify justification, this is in addherence "+ >> "to std sprintf which defaults to right-justification, "+ >> "this version also supports centre and right justification."); Two columns next to each other (any The - is to specify justification, number of columns will of course this is in addherence to std work) independantly word-wrapped, sprintf which defaults to can be useful. right-justification, this version also supports centre and right justification. (7) Result: 426 > write("%-$*s\n", screen_width, >> "Given a\nlist of\nslosh-n\nseparated\n'words',\nthis option\n"+ >> "creates a\ntable out\nof them\nthe number of\ncolumns\n"+ >> "be forced\nby specifying a\npresision.\nThe most obvious\n"+ >> "use is for\nformatted\nls output."); Given a list of slosh-n separated 'words', this option creates a table out of them the number of columns be forced by specifying a presision. The most obvious use is for formatted ls output. (8) Result: 312 > write("%-#*s\n", screen_width, >> "Given a\nlist of\nslosh-n\nseparated\n'words',\nthis option\n"+ >> "creates a\ntable out\nof them\nthe number of\ncolumns\n"+ >> "be forced\nby specifying a\npresision.\nThe most obvious\n"+ >> "use is for\nformatted\nls output."); Given a creates a by specifying a list of table out presision. slosh-n of them The most obvious separated the number of use is for 'words', columns formatted this option be forced ls output. (9) Result: 312 > sample = ([ "align":"left", "valign":"middle" ]); (10) Result: ([ /* 2 elements */ "align":"left", "valign":"middle" ]) > write("<td%{ %s='%s'%}>\n", (array)sample); <td valign='middle' align='left'> (11) Result: 34 > write("Of course all the simple printf options "+ >> "are supported:\n %s: %d %x %o %c\n", >> "65 as decimal, hex, octal and a char", >> 65, 65, 65, 65); Of course all the simple printf options are supported: 65 as decimal, hex, octal and a char: 65 41 101 A (12) Result: 106 > write("%[0]d, %[0]x, %[0]X, %[0]o, %[0]c\n", 75); 75, 4b, 4B, 113, K (13) Result: 19 > write("%|*s\n",screen_width, "THE END"); THE END (14) Result: 71
lfun::_sprintf()
array(int|string|array(string)) getgrgid(int gid)
Get the group entry for the group with the id gid using the systemfunction getgrid(3).
The id of the group
An array with the information about the group
| ||||||||||
getgrent() getgrnam()
array(int|string|array(string)) getgrnam(string str)
Get the group entry for the group with the name str using the systemfunction getgrnam(3).
The name of the group
An array with the information about the group
| ||||||||||
getgrent() getgrgid()
array(int|string) getpwnam(string str)
Get the user entry for login str using the systemfunction getpwnam(3).
The login name of the user whos userrecord is requested.
An array with the information about the user
| ||||||||||||||||
getpwuid() getpwent()
array(int|string) getpwuid(int uid)
Get the user entry for UID uid using the systemfunction getpwuid(3).
The uid of the user whos userrecord is requested.
An array with the information about the user
| ||||||||||||||||
getpwnam() getpwent()
array(array(int|string)) get_all_users()
Returns an array with all users in the system.
An array with arrays of userinfo as in getpwent .
getpwent() getpwnam() getpwuid()
array(array(int|string|array(string))) get_all_groups()
Returns an array of arrays with all groups in the system groups source. Each element in the returned array has the same structure as in getgrent function.
The groups source is system dependant. Refer to your system manuals for information about how to set the source.
| ||||
getgrent()
array(int) get_groups_for_user(int|string user)
Gets all groups which a given user is a member of.
UID or loginname of the user
| ||||
get_all_groups() getgrgid() getgrnam() getpwuid() getpwnam()
int(0..1) connect_lock(void|int enable)
Enable or disable a mutex that serializes all ODBC SQLConnect calls (i.e. when ODBC connections are created). This lock might be necessary to work around bugs in ODBC drivers.
Enables the mutex if nonzero, disables it otherwise. The state is not changed if this argument is left out.
The old state of the flag.
This is currently enabled by default due to bugs in the current FreeTDS library (version 0.63), but that might change if the demand for this kludge ceases in the future. Therefore, if this setting is important to you then always set it explicitly. Hopefully most users don't need to bother with it.
multiset aggregate_multiset(mixed ... elems)
Construct a multiset with the arguments as indices. The multiset
will not contain any values. This method is most useful when
constructing multisets with map or similar; generally, the
multiset literal syntax is handier: (<elem1, elem2, ...>)
With it, it's also possible to construct a multiset with values:
(<index1: value1, index2: value2, ...>)
sizeof() , multisetp() , mkmultiset()
int(0..1) `!=(mixed arg1, mixed arg2, mixed ... extras)
Inequality test.
Every expression with the != operator becomes a call to
this function, i.e. a!=b is the same as
predef::`!=(a,b).
This is the inverse of `==() ; see that function for further details.
Returns 1 if the test is successful, 0
otherwise.
`==()
int(0..1) `==(mixed arg1, mixed arg2, mixed ... extras)
Equality test.
Every expression with the == operator becomes a call to
this function, i.e. a==b is the same as
predef::`==(a,b).
If more than two arguments are given, each argument is compared with the following one as described below, and the test is successful iff all comparisons are successful.
If the first argument is an object with an lfun::`==() , that function is called with the second as argument, unless the second argument is the same as the first argument. The test is successful iff its result is nonzero (according to `! ).
Otherwise, if the second argument is an object with an lfun::`==() , that function is called with the first as argument, and the test is successful iff its result is nonzero (according to `! ).
Otherwise, if the arguments are of different types, the test is unsuccessful. Function pointers to programs are automatically converted to program pointers if necessary, though.
Otherwise the test depends on the type of the arguments:
|
Returns 1 if the test is successful, 0
otherwise.
Floats and integers are not automatically converted to test
against each other, so e.g. 0==0.0 is false.
Programs are not automatically converted to types to be compared type-wise.
`!() , `!=()
int(0..1) `<(mixed arg1, mixed arg2, mixed ... extras)
Less than test.
Every expression with the < operator becomes a call to
this function, i.e. a<b is the same as
predef::`<(a,b).
Returns 1 if the test is successful, 0
otherwise.
`<=() , `>() , `>=()
int(0..1) `<=(mixed arg1, mixed arg2, mixed ... extras)
Less than or equal test.
Every expression with the <= operator becomes a call to
this function, i.e. a<=b is the same as
predef::`<=(a,b).
Returns 1 if the test is successful, 0
otherwise.
For total orders, e.g. integers, this is the inverse of `>() .
`<() , `>() , `>=()
int(0..1) `>(mixed arg1, mixed arg2, mixed ... extras)
Greater than test.
Every expression with the > operator becomes a call to
this function, i.e. a>b is the same as
predef::`>(a,b).
Returns 1 if the arguments are strictly decreasing, and
0 (zero) otherwise.
`<() , `<=() , `>=()
int(0..1) `>=(mixed arg1, mixed arg2, mixed ... extras)
Greater than or equal test.
Every expression with the >= operator becomes a call to
this function, i.e. a>=b is the same as
predef::`>=(a,b).
Returns 1 if the test is successful, 0
otherwise.
For total orders, e.g. integers, this is the inverse of `<() .
`<=() , `>() , `<()
mixed `+(mixed arg)
mixed `+(object arg, mixed ... more)
int `+(int arg, int ... more)
float `+(float|int arg, float|int ... more)
string `+(string|float|int arg, string|float|int ... more)
array `+(array arg, array ... more)
mapping `+(mapping arg, mapping ... more)
multiset `+(multiset arg, multiset ... more)
Addition/concatenation.
Every expression with the + operator becomes a call to
this function, i.e. a+b is the same as
predef::`+(a,b). Longer + expressions are
normally optimized to one call, so e.g. a+b+c becomes
predef::`+(a,b,c).
If there's a single argument, that argument is returned.
If arg is an object with only one reference and an lfun::`+=() , that function is called with the rest of the arguments, and its result is returned.
Otherwise, if arg is an object with an lfun::`+() , that function is called with the rest of the arguments, and its result is returned.
Otherwise, if any of the other arguments is an object that has an lfun::``+() , the first such function is called with the arguments leading up to it, and `+() is then called recursively with the result and the rest of the arguments.
Otherwise, if arg is UNDEFINED and the other arguments are
either arrays, mappings or multisets, the first argument is
ignored and the remaining are added together as described below.
This is useful primarily when appending to mapping values since
m[x] += ({foo}) will work even if m[x] doesn't
exist yet.
Otherwise the result depends on the argument types:
|
The function is not destructive on the arguments - the result is always a new instance.
In Pike 7.0 and earlier the addition order was unspecified.
The treatment of UNDEFINED was new in Pike 7.0.
`-() , lfun::`+() , lfun::``+()
mixed `-(mixed arg1)
mixed `-(mixed arg1, mixed arg2, mixed ... extras)
mixed `-(object arg1, mixed arg2)
mixed `-(mixed arg1, object arg2)
int `-(int arg1, int arg2)
float `-(float arg1, int|float arg2)
float `-(int|float arg1, float arg2)
string `-(string arg1, string arg2)
array `-(array arg1, array arg2)
mapping `-(mapping arg1, array arg2)
mapping `-(mapping arg1, mapping arg2)
mapping `-(mapping arg1, multiset arg2)
multiset `-(multiset arg1, multiset arg2)
Negation/subtraction/set difference.
Every expression with the - operator becomes a call to
this function, i.e. -a is the same as
predef::`-(a) and a-b is the same as
predef::`-(a,b). Longer - expressions are
normally optimized to one call, so e.g. a-b-c becomes
predef::`-(a,b,c).
If there's a single argument, that argument is returned negated. If arg1 is an object with an lfun::`-() , that function is called without arguments, and its result is returned.
If there are more than two arguments the result is:
`-(`-(arg1 , arg2 ), @extras ).
Otherwise, if arg1 is an object with an lfun::`-() , that function is called with arg2 as argument, and its result is returned.
Otherwise, if arg2 is an object with an lfun::``-() , that function is called with arg1 as argument, and its result is returned.
Otherwise the result depends on the argument types:
arg1 can have any of the following types:
|
The function is not destructive on the arguments - the result is always a new instance.
In Pike 7.0 and earlier the subtraction order was unspecified.
`+()
mixed `&(mixed arg1)
mixed `&(mixed arg1, mixed arg2, mixed ... extras)
mixed `&(object arg1, mixed arg2)
mixed `&(mixed arg1, object arg2)
int `&(int arg1, int arg2)
string `&(string arg1, string arg2)
array `&(array arg1, array arg2)
mapping `&(mapping arg1, mapping arg2)
mapping `&(mapping arg1, array arg2)
mapping `&(mapping arg1, multiset arg2)
multiset `&(multiset arg1, multiset arg2)
type(mixed) `&(type(mixed)|program arg1, type(mixed)|program arg2)
Bitwise and/intersection.
Every expression with the & operator becomes a call to
this function, i.e. a&b is the same as
predef::`&(a,b).
If there's a single argument, that argument is returned.
If there are more than two arguments the result is:
`&(`&(arg1 , arg2 ), @extras ).
Otherwise, if arg1 is an object with an lfun::`&() , that function is called with arg2 as argument, and its result is returned.
Otherwise, if arg2 is an object with an lfun::``&() , that function is called with arg1 as argument, and its result is returned.
Otherwise the result depends on the argument types:
arg1 can have any of the following types:
|
The function is not destructive on the arguments - the result is always a new instance.
`|() , lfun::`&() , lfun::``&()
mixed `|(mixed arg1)
mixed `|(mixed arg1, mixed arg2, mixed ... extras)
mixed `|(object arg1, mixed arg2)
mixed `|(mixed arg1, object arg2)
int `|(int arg1, int arg2)
string `|(string arg1, string arg2)
array `|(array arg1, array arg2)
mapping `|(mapping arg1, mapping arg2)
multiset `|(multiset arg1, multiset arg2)
type(mixed) `|(program|type(mixed) arg1, program|type(mixed) arg2)
Bitwise or/union.
Every expression with the | operator becomes a call to
this function, i.e. a|b is the same as
predef::`|(a,b).
If there's a single argument, that argument is returned.
If there are more than two arguments, the result is:
`|(`|(arg1 , arg2 ), @extras ).
Otherwise, if arg1 is an object with an lfun::`|() , that function is called with arg2 as argument, and its result is returned.
Otherwise, if arg2 is an object with an lfun::``|() , that function is called with arg1 as argument, and its result is returned.
Otherwise the result depends on the argument types:
arg1 can have any of the following types:
|
The function is not destructive on the arguments - the result is always a new instance.
`&() , lfun::`|() , lfun::``|()
mixed `^(mixed arg1)
mixed `^(mixed arg1, mixed arg2, mixed ... extras)
mixed `^(object arg1, mixed arg2)
mixed `^(mixed arg1, object arg2)
int `^(int arg1, int arg2)
string `^(string arg1, string arg2)
array `^(array arg1, array arg2)
mapping `^(mapping arg1, mapping arg2)
multiset `^(multiset arg1, multiset arg2)
type(mixed) `^(program|type(mixed) arg1, program|type(mixed) arg2)
Exclusive or.
Every expression with the ^ operator becomes a call to
this function, i.e. a^b is the same as
predef::`^(a,b).
If there's a single argument, that argument is returned.
If there are more than two arguments, the result is:
`^(`^(arg1 , arg2 ), @extras ).
Otherwise, if arg1 is an object with an lfun::`^() , that function is called with arg2 as argument, and its result is returned.
Otherwise, if arg2 is an object with an lfun::``^() , that function is called with arg1 as argument, and its result is returned.
Otherwise the result depends on the argument types:
arg1 can have any of the following types:
|
The function is not destructive on the arguments - the result is always a new instance.
`&() , `|() , lfun::`^() , lfun::``^()
int `<<(int arg1, int arg2)
mixed `<<(object arg1, int|object arg2)
mixed `<<(int arg1, object arg2)
Left shift.
Every expression with the << operator becomes a call to
this function, i.e. a<<b is the same as
predef::`<<(a,b).
If arg1 is an object that implements lfun::`<<() , that function will be called with arg2 as the single argument.
If arg2 is an object that implements lfun::``<<() , that function will be called with arg1 as the single argument.
Otherwise arg1 will be shifted arg2 bits left.
`>>()
int `>>(int arg1, int arg2)
mixed `>>(object arg1, int|object arg2)
mixed `>>(int arg1, object arg2)
Right shift.
Every expression with the >> operator becomes a call to
this function, i.e. a>>b is the same as
predef::`>>(a,b).
If arg1 is an object that implements lfun::`>>() , that function will be called with arg2 as the single argument.
If arg2 is an object that implements lfun::``>>() , that function will be called with arg1 as the single argument.
Otherwise arg1 will be shifted arg2 bits right.
`<<()
mixed `*(mixed arg1)
mixed `*(object arg1, mixed arg2, mixed ... extras)
mixed `*(mixed arg1, object arg2)
array `*(array arg1, int arg2)
array `*(array arg1, float arg2)
string `*(string arg1, int arg2)
string `*(string arg1, float arg2)
string `*(array(string) arg1, string arg2)
array `*(array(array) arg1, array arg2)
float `*(float arg1, int|float arg2)
float `*(int arg1, float arg2)
int `*(int arg1, int arg2)
mixed `*(mixed arg1, mixed arg2, mixed ... extras)
Multiplication/repetition/implosion.
Every expression with the * operator becomes a call to
this function, i.e. a*b is the same as
predef::`*(a,b). Longer * expressions are
normally optimized to one call, so e.g. a*b*c becomes
predef::`*(a,b,c).
If there's a single argument, that argument will be returned.
If the first argument is an object that implements lfun::`*() , that function will be called with the rest of the arguments.
If there are more than two arguments, the result will be
`*(`*(arg1 , arg2 ), @extras ).
If arg2 is an object that implements lfun::``*() , that function will be called with arg1 as the single argument.
Otherwise the result will be as follows:
arg1 can have any of the following types:
|
In Pike 7.0 and earlier the multiplication order was unspecified.
`+() , `-() , `/() , lfun::`*() , lfun::``*()
mixed `/(object arg1, mixed arg2)
mixed `/(mixed arg1, object arg2)
array(string) `/(string arg1, int arg2)
array(string) `/(string arg1, float arg2)
array(array) `/(array arg1, int arg2)
array(array) `/(array arg1, float arg2)
array(string) `/(string arg1, string arg2)
array(array) `/(array arg1, array arg2)
float `/(float arg1, int|float arg2)
float `/(int arg1, float arg2)
int `/(int arg1, int arg2)
mixed `/(mixed arg1, mixed arg2, mixed ... extras)
Division/split.
Every expression with the / operator becomes a call to
this function, i.e. a/b is the same as
predef::`/(a,b).
If there are more than two arguments, the result will be
`/(`/(arg1 , arg2 ), @extras ).
If arg1 is an object that implements lfun::`/() , that function will be called with arg2 as the single argument.
If arg2 is an object that implements lfun::``/() , that function will be called with arg1 as the single argument.
Otherwise the result will be as follows:
arg1 can have any of the following types:
|
Unlike in some languages, the function f(x) = x/n (x and n integers) behaves in a well-defined way and is always rounded down. When you increase x, f(x) will increase with one for each n:th increment. For all x, (x + n) / n = x/n + 1; crossing zero is not special. This also means that / and % are compatible, so that a = b*(a/b) + a%b for all a and b.
`%
mixed `%(object arg1, mixed arg2)
mixed `%(mixed arg1, object arg2)
string `%(string arg1, int arg2)
array `%(array arg1, int arg2)
float `%(float arg1, float|int arg2)
float `%(int arg1, float arg2)
int `%(int arg1, int arg2)
Modulo.
Every expression with the % operator becomes a call to
this function, i.e. a%b is the same as
predef::`%(a,b).
If arg1 is an object that implements lfun::`%() then that function will be called with arg2 as the single argument.
If arg2 is an object that implements lfun::``%() then that function will be called with arg2 as the single argument.
Otherwise the result will be as follows:
arg1 can have any of the following types:
|
For numbers, this means that
a % b always has the same sign as b (typically b is positive; array size, rsa modulo, etc, and a varies a lot more than b).
The function f(x) = x % n behaves in a sane way; as x increases, f(x) cycles through the values 0,1, ..., n-1, 0, .... Nothing strange happens when you cross zero.
The % operator implements the binary "mod" operation, as defined by Donald Knuth (see the Art of Computer Programming, 1.2.4). It should be noted that Pike treats %-by-0 as an error rather than returning 0, though.
/ and % are compatible, so that a = b*(a/b) + a%b for all a and b.
`/
int(0..1) `!(object|function arg)
int(1..1) `!(int(0..0) arg)
int(0..0) `!(mixed arg)
Logical not.
Every expression with the ! operator becomes a call to
this function, i.e. !a is the same as
predef::`!(a).
It's also used when necessary to test truth on objects, i.e. in
a statement if (o) ... where o is an object, the
test becomes the equivalent of !!o so that any
lfun::`!() the object might have gets called.
If arg is an object that implements lfun::`!() , that function will be called.
If arg is 0 (zero), a destructed object, or a function in a
destructed object, 1 will be returned.
Otherwise 0 (zero) will be returned.
No float is considered false, not even 0.0.
`==() , `!=() , lfun::`!()
mixed `~(object arg)
int `~(int arg)
float `~(float arg)
type(mixed) `~(type(mixed)|program arg)
string `~(string arg)
Complement/inversion.
Every expression with the ~ operator becomes a call to
this function, i.e. ~a is the same as
predef::`~(a).
The result will be as follows:
arg can have any of the following types:
|
`!() , lfun::`~()
mixed `[..](object arg, mixed start, int start_type, mixed end, int end_type)
string `[..](string arg, int start, int start_type, int end, int end_type)
array `[..](array arg, int start, int start_type, int end, int end_type)
Extracts a subrange.
This is the function form of expressions with the [..]
operator. arg is the thing from which the subrange is to be
extracted. start is the lower bound of the subrange and
end the upper bound.
start_type and end_type specifies how the start and end indices, respectively, are to be interpreted. The types are either Pike.INDEX_FROM_BEG , Pike.INDEX_FROM_END or Pike.OPEN_BOUND . In the last case, the index value is insignificant.
The relation between [..] expressions and this function
is therefore as follows:
a[i..j] <=> `[..] (a, i, Pike.INDEX_FROM_BEG, j, Pike.INDEX_FROM_BEG)
a[i..<j] <=> `[..] (a, i, Pike.INDEX_FROM_BEG, j, Pike.INDEX_FROM_END)
a[i..] <=> `[..] (a, i, Pike.INDEX_FROM_BEG, 0, Pike.OPEN_BOUND)
a[<i..j] <=> `[..] (a, i, Pike.INDEX_FROM_END, j, Pike.INDEX_FROM_BEG)
a[<i..<j] <=> `[..] (a, i, Pike.INDEX_FROM_END, j, Pike.INDEX_FROM_END)
a[<i..] <=> `[..] (a, i, Pike.INDEX_FROM_END, 0, Pike.OPEN_BOUND)
a[..j] <=> `[..] (a, 0, Pike.OPEN_BOUND, j, Pike.INDEX_FROM_BEG)
a[..<j] <=> `[..] (a, 0, Pike.OPEN_BOUND, j, Pike.INDEX_FROM_END)
a[..] <=> `[..] (a, 0, Pike.OPEN_BOUND, 0, Pike.OPEN_BOUND)
The subrange is specified as follows by the two bounds:
If the lower bound refers to an index before the lowest allowable (typically zero) then it's taken as an open bound which starts at the first index (without any error).
Correspondingly, if the upper bound refers to an index past the last allowable then it's taken as an open bound which ends at the last index (without any error).
If the lower bound is less than or equal to the upper bound, then the subrange is the inclusive range between them, i.e. from and including the element at the lower bound and up to and including the element at the upper bound.
If the lower bound is greater than the upper bound then the result is an empty subrange (without any error).
The returned value depends on the type of arg :
arg can have any of the following types:
|
lfun::`[..] , `[]
mixed `[](object arg, mixed index)
mixed `[](object arg, string index)
function `[](int arg, string index)
int `[](string arg, int index)
mixed `[](array arg, int index)
mixed `[](array arg, mixed index)
mixed `[](mapping arg, mixed index)
int(0..1) `[](multiset arg, mixed index)
mixed `[](program arg, string index)
mixed `[](object arg, mixed start, mixed end)
string `[](string arg, int start, int end)
array `[](array arg, int start, int end)
Indexing.
This is the function form of expressions with the []
operator, i.e. a[i] is the same as
predef::`[](a,i).
If arg is an object that implements lfun::`[]() , that function is called with the index argument.
Otherwise, the action depends on the type of arg :
arg can have any of the following types:
|
As a compatibility measure, this function also performs range operations if it's called with three arguments. In that case it becomes equivalent to:
`[..] (arg, start, Pike.INDEX_FROM_BEG , end, Pike.INDEX_FROM_BEG )
See `[..] for further details.
An indexing expression in an lvalue context, i.e. where the index is being assigned a new value, uses `[]= instead of this function.
`->() , lfun::`[]() , `[]= , `[..]
mixed `->(object arg, string index)
mixed `->(int arg, string index)
mixed `->(array arg, string index)
mixed `->(mapping arg, string index)
int(0..1) `->(multiset arg, string index)
mixed `->(program arg, string index)
Arrow indexing.
Every non-lvalue expression with the -> operator becomes
a call to this function. a->b is the same as
predef::`^(a,"b") where "b" is the symbol
b in string form.
This function behaves like `[] , except that the index is passed literally as a string instead of being evaluated.
If arg is an object that implements lfun::`->() , that function will be called with index as the single argument.
Otherwise the result will be as follows:
arg can have any of the following types:
|
In an expression a->b, the symbol b can be any
token that matches the identifier syntax - keywords are
disregarded in that context.
An arrow indexing expression in an lvalue context, i.e. where the index is being assigned a new value, uses `->= instead of this function.
`[]() , lfun::`->() , ::`->() , `->=
mixed `[]=(object arg, mixed index, mixed val)
mixed `[]=(object arg, string index, mixed val)
mixed `[]=(array arg, int index, mixed val)
mixed `[]=(mapping arg, mixed index, mixed val)
int(0..1) `[]=(multiset arg, mixed index, int(0..1) val)
Index assignment.
Every lvalue expression with the [] operator becomes a
call to this function, i.e. a[b]=c is the same as
predef::`[]=(a,b,c).
If arg is an object that implements lfun::`[]=() , that function will be called with index and val as the arguments.
arg can have any of the following types:
|
val will be returned.
An indexing expression in a non-lvalue context, i.e. where the index is being queried instead of assigned, uses `[] instead of this function.
`->=() , lfun::`[]=() , `[]
mixed `->=(object arg, string index, mixed val)
mixed `->=(mapping arg, string index, mixed val)
int(0..1) `->=(multiset arg, string index, int(0..1) val)
Arrow index assignment.
Every lvalue expression with the -> operator becomes a
call to this function, i.e. a->b=c is the same as
predef::`->=(a,"b",c) where "b" is the symbol
b in string form.
This function behaves like `[]= , except that the index is passed literally as a string instead of being evaluated.
If arg is an object that implements lfun::`->=() , that function will be called with index and val as the arguments.
arg can have any of the following types:
|
val will be returned.
In an expression a->b=c, the symbol b can be any
token that matches the identifier syntax - keywords are
disregarded in that context.
An arrow indexing expression in a non-lvalue context, i.e. where the index is being queried instead of assigned, uses `-> instead of this function.
`[]=() , lfun::`->=() , `->
int sizeof(string arg)
int sizeof(array arg)
int sizeof(mapping arg)
int sizeof(multiset arg)
int sizeof(object arg)
Size query.
The result will be as follows:
arg can have any of the following types:
|
lfun::_sizeof()
string encode_value(mixed value, Codec|void codec)
Code a value into a string.
This function takes a value, and converts it to a string. This string can then be saved, sent to another Pike process, packed or used in any way you like. When you want your value back you simply send this string to decode_value() and it will return the value you encoded.
Almost any value can be coded, mappings, floats, arrays, circular structures etc.
If codec is specified, it's used as the codec for the decode. If no codec is specified, the current master object will be used.
If codec ->nameof(o) returns UNDEFINED for an
object, val = o->encode_object(o) will be called. The
returned value will be passed to o->decode_object(o, val)
when the object is decoded.
When only simple types like int, floats, strings, mappings, multisets and arrays are encoded, the produced string is very portable between pike versions. It can at least be read by any later version.
The portability when objects, programs and functions are involved depends mostly on the codec. If the byte code is encoded, i.e. when Pike programs are actually dumped in full, then the string can probably only be read by the same pike version.
decode_value() , sprintf() , encode_value_canonic()
string encode_value_canonic(mixed value, object|void codec)
Code a value into a string on canonical form.
Takes a value and converts it to a string on canonical form, much like encode_value() . The canonical form means that if an identical value is encoded, it will produce exactly the same string again, even if it's done at a later time and/or in another Pike process. The produced string is compatible with decode_value() .
Note that this function is more restrictive than encode_value() with respect to the types of values it can encode. It will throw an error if it can't encode to a canonical form.
encode_value() , decode_value()
mixed decode_value(string coded_value, void|Codec codec)
Decode a value from the string coded_value .
This function takes a string created with encode_value() or encode_value_canonic() and converts it back to the value that was coded.
If codec is specified, it's used as the codec for the decode. If no codec is specified, the current master object will be used.
encode_value() , encode_value_canonic()
constant UNDEFINED
The undefined value; ie a zero for which zero_type() returns 1.
constant this
Builtin read only variable that evaluates to the current object.
this_program , this_object()
constant this_program
Builtin constant that evaluates to the current program.
this , this_object()
constant __null_program
Program used internally by the compiler to create objects that are later modified into instances of the compiled program by the compiler.
__placeholder_object
constant __placeholder_object
Object used internally by the compiler.
__null_program
mixed call_out(function f, float|int delay, mixed ... args)
void _do_call_outs()
int find_call_out(function f)
int find_call_out(mixed id)
int remove_call_out(function f)
int remove_call_out(function id)
array(array) call_out_info()
These are aliases for the corresponding functions in Pike.DefaultBackend .
Pike.Backend()->call_out() , Pike.Backend()->_do_call_outs() , Pike.Backend()->find_call_out() , Pike.Backend()->remove_call_out() , Pike.Backend()->call_out_info()
mixed `()(function fun, mixed ... args)
mixed call_function(function fun, mixed ... args)
Call a function.
Calls the function fun with the arguments specified by args .
lfun::`()()
Iterator get_iterator(object|array|mapping|multiset|string data)
Creates and returns a canonical iterator for data .
|
This function is used by foreach to get an iterator for an object.
Iterator , lfun::_get_iterator
program load_module(string module_name)
Load a binary module.
This function loads a module written in C or some other language into Pike. The module is initialized and any programs or constants defined will immediately be available.
When a module is loaded the C function pike_module_init() will be called to initialize it. When Pike exits pike_module_exit() will be called. These two functions must be available in the module.
The current working directory is normally not searched for
dynamic modules. Please use "./name.so" instead of just
"name.so" to load modules from the current directory.
void signal(int sig, function(int|void:void) callback)
void signal(int sig)
Trap signals.
This function allows you to trap a signal and have a function called when the process receives a signal. Although it IS possible to trap SIGBUS, SIGSEGV etc. I advice you not to. Pike should not receive any such signals and if it does it is because of bugs in the Pike interpreter. And all bugs should be reported, no matter how trifle.
The callback will receive the signal number as its only argument.
See the documentation for kill() for a list of signals.
If no second argument is given, the signal handler for that signal is restored to the default handler.
If the second argument is zero, the signal will be completely ignored.
kill() , signame() , signum()
int signum(string sig)
Get a signal number given a descriptive string.
This function is the inverse of signame() .
signame() , kill() , signal()
string signame(int sig)
Returns a string describing the signal sig .
kill() , signum() , signal()
int set_priority(string level, int|void pid)
object fork()
Fork the process in two.
Fork splits the process in two, and for the parent it returns a pid object for the child. Refer to your Unix manual for further details.
This function can cause endless bugs if used without proper care.
This function is disabled when using threads.
This function is not available on all platforms.
The most common use for fork is to start sub programs, which is better done with Process.create_process() .
Process.create_process()
void kill(int pid, int signal)
Send a signal to another process. Returns nonzero if it worked, zero otherwise. errno may be used in the latter case to find out what went wrong.
Some signals and their supposed purpose:
|
Note that you have to use signame to translate the name of a signal to its number.
Note that the kill function is not available on platforms that do not support signals. Some platforms may also have signals not listed here.
signal() , signum() , signame() , fork()
int getpid()
Returns the process ID of this process.
System.getppid() , System.getpgrp()
int alarm(int seconds)
Set an alarm clock for delivery of a signal.
alarm() arranges for a SIGALRM signal to be delivered to the process in seconds seconds.
If seconds is 0 (zero), no new alarm will be scheduled.
Any previous alarms will in any case be canceled.
Returns the number of seconds remaining until any previously scheduled alarm was due to be delivered, or zero if there was no previously scheduled alarm.
This function is only available on platforms that support signals.
ualarm() , signal() , call_out()
int ualarm(int useconds)
Set an alarm clock for delivery of a signal.
alarm() arranges for a SIGALRM signal to be delivered to the process in useconds microseconds.
If useconds is 0 (zero), no new alarm will be scheduled.
Any previous alarms will in any case be canceled.
Returns the number of microseconds remaining until any previously scheduled alarm was due to be delivered, or zero if there was no previously scheduled alarm.
This function is only available on platforms that support signals.
alarm() , signal() , call_out()
void atexit(function callback)
This function puts the callback in a queue of callbacks to call when pike exits. The call order is reversed, i.e. callbacks that have been added earlier are called after callback .
Please note that atexit callbacks are not called if Pike exits abnormally.
exit() , _exit()
string cpp(string data, string|void current_file, int|string|void charset, object|void handler, void|int compat_major, void|int compat_minor, void|int picky_cpp)
Run a string through the preprocessor.
Preprocesses the string data with Pike's builtin ANSI-C look-alike
preprocessor. If the current_file argument has not been specified,
it will default to "-". charset defaults to "ISO-10646".
compile()
string version()
Report the version of Pike. Does the same as
sprintf("Pike v%d.%d release %d", __REAL_VERSION__,
__REAL_MINOR__, __REAL_BUILD__);
__VERSION__ , __MINOR__ , __BUILD__ , __REAL_VERSION__ , __REAL_MINOR__ , __REAL_BUILD__ ,
int sscanf(string data, string format, mixed ... lvalues)
The purpose of sscanf is to match a string data against a format string and place the matching results into a list of variables. The list of lvalues are destructively modified (which is only possible because sscanf really is an opcode, rather than a pike function) with the values extracted from the data according to the format specification. Only the variables up to the last matching directive of the format string are touched.
The format string can contain strings separated by special matching directives like %d, %s%c and %f. Every such directive corresponds to one of the lvalues , in order they are listed. An lvalue is the name of a variable, a name of a local variable, an index in an array, mapping or object. It is because of these lvalues that sscanf can not be implemented as a normal function.
Whenever a percent character is found in the format string, a match is performed, according to which operator and modifiers follow it:
|
Similar to sprintf , you may supply modifiers between the % character and the operator, to slightly change its behaviour from the default:
|
Sscanf does not use backtracking. Sscanf simply looks at the format string up to the next % and tries to match that with the string. It then proceeds to look at the next part. If a part does not match, sscanf immediately returns how many % were matched. If this happens, the lvalues for % that were not matched will not be changed.
// a will be assigned "oo" and 1 will be returned sscanf("foo", "f%s", a);
// a will be 4711 and b will be "bar", 2 will be returned sscanf("4711bar", "%d%s", a, b);
// a will be 4711, 2 will be returned sscanf("bar4711foo", "%*s%d", a);
// a will become "test", 2 will be returned sscanf(" \t test", "%*[ \t]%s", a);
// Remove "the " from the beginning of a string // If 'str' does not begin with "the " it will not be changed sscanf(str, "the %s", str);
// It is also possible to declare a variable directly in the sscanf call; // another reason for sscanf not to be an ordinary function:
sscanf("abc def", "%s %s", string a, string b);
The number of directives matched in the format string. Note that a string directive (%s or %[]) counts as a match even when matching just the empty string (which either may do).
sprintf , array_sscanf
array array_sscanf(string data, string format)
This function works just like sscanf() , but returns the matched results in an array instead of assigning them to lvalues. This is often useful for user-defined sscanf strings.
sscanf() , `/()
string basetype(mixed x)
Same as sprintf("%t",x);
sprintf()
array column(array data, mixed index)
Extract a column from a two-dimensional array.
This function is exactly equivalent to:
map(data , lambda(mixed x,mixed y) { return x[y]; }, index )
Except of course it is a lot shorter and faster. That is, it indices every index in the array data on the value of the argument index and returns an array with the results.
rows()
multiset mkmultiset(array a)
This function creates a multiset from an array.
aggregate_multiset()
int trace(int level, void|string facility, void|int all_threads)
This function changes the trace level for the subsystem identified by facility to level . If facility is zero or left out, it changes the global trace level which affects all subsystems.
Enabling tracing causes messages to be printed to stderr. A higher trace level includes the output from all lower levels. The lowest level is zero which disables all trace messages.
See the -t command-line option for more information.
If facility is specified then there is typically only one trace level for it, i.e. it's an on-or-off toggle. The global trace levels, when facility isn't specified, are:
|
Valid facilities are:
|
Trace levels are normally thread local, so changes affect only the current thread. To change the level in all threads, pass a nonzero value in this argument.
The old trace level in the current thread is returned.
string ctime(int timestamp)
Convert the output from a previous call to time() into a readable string containing the current year, month, day and time.
Like localtime , this function might throw an error if the ctime(2) call failed on the system. It's platform dependent what time ranges that function can handle, e.g. Windows doesn't handle a negative timestamp .
time() , localtime() , mktime() , gmtime()
mapping mkmapping(array ind, array val)
Make a mapping from two arrays.
Makes a mapping ind[x] :val[x] , 0 <= x < sizeof(ind).
ind and val must have the same size.
This is the inverse operation of indices() and values() .
indices() , values()
mixed m_delete(object|mapping map, mixed index)
If map is an object that implements lfun::_m_delete() , that function will be called with index as its single argument.
Otherwise if map is a mapping the entry with index index will be removed from map destructively.
If the mapping does not have an entry with index index , nothing is done.
The value that was removed will be returned.
Note that m_delete() changes map destructively.
mappingp()
int get_weak_flag(array|mapping|multiset m)
Returns the weak flag settings for m . It's a combination of Pike.WEAK_INDICES and Pike.WEAK_VALUES .
program __empty_program(int|void line, string|void file)
string function_name(function f)
Return the name of the function f .
If f is a global function defined in the runtime 0
(zero) will be returned.
function_object()
object function_object(function f)
Return the object the function f is in.
If f is a global function defined in the runtime 0
(zero) will be returned.
Zero will also be returned if f is a constant in the parent class. In that case function_program() can be used to get the parent program.
function_name() , function_program()
program function_program(function|program f)
Return the program the function f is in.
If f is a global function defined in the runtime 0
(zero) will be returned.
function_name() , function_object()
mixed random(object o)
If random is called with an object, lfun::random will be called in the object.
lfun::_random
int random(int max)
float random(float max)
This function returns a random number in the range 0 - max -1.
random_seed()
mixed random(array|multiset x)
Returns a random element from x .
array random(mapping m)
Returns a random index-value pair from the mapping.
array(Pike.BacktraceFrame) backtrace()
FIXME: This documentation is not up to date!
Get a description of the current call stack.
The description is returned as an array with one entry for each call frame on the stack.
Each entry has this format:
| ||||||||||
The current call frame will be last in the array.
Please note that the frame order may be reversed in a later version (than 7.1) of Pike to accommodate for deferred backtraces.
Note that the arguments reported in the backtrace are the current values of the variables, and not the ones that were at call-time. This can be used to hide sensitive information from backtraces (eg passwords).
catch() , throw()
_disable_threads _disable_threads()
This function first posts a notice to all threads that it is time to stop. It then waits until all threads actually *have* stopped, and then then returns a lock object. All other threads will be blocked from running until that object has been freed/destroyed.
It's mainly useful to do things that require a temporary uid/gid change, since on many OS the effective user and group applies to all threads.
You should make sure that the returned object is freed even if some kind of error is thrown. That means in practice that it should only have references (direct or indirect) from function local variables. Also, it shouldn't be referenced from cyclic memory structures, since those are only destructed by the periodic gc. (This advice applies to mutex locks in general, for that matter.)
mapping aggregate_mapping(mixed ... elems)
Construct a mapping.
Groups the arguments together two and two in key-index pairs and
creates a mapping of those pairs. Generally, the mapping literal
syntax is handier: ([ key1:val1, key2:val2, ... ])
sizeof() , mappingp() , mkmapping()
int equal(mixed a, mixed b)
This function checks if the values a and b are equal.
For all types but arrays, multisets and mappings, this operation is
the same as doing a == b .
For arrays, mappings and multisets however, their contents are checked
recursively, and if all their contents are the same and in the same
place, they are considered equal.
copy_value()
array aggregate(mixed ... elements)
Construct an array with the arguments as indices.
This function could be written in Pike as:
array aggregate(mixed ... elems) { return elems; }
Arrays are dynamically allocated there is no need to declare them
like int a[10]=allocate(10); (and it isn't possible either) like
in C, just array(int) a=allocate(10); will do.
sizeof() , arrayp() , allocate()
__deprecated__ int hash_7_4(string s)
__deprecated__ int hash_7_4(string s, int max)
7.4::hash()
__deprecated__ int hash_7_0(string s)
__deprecated__ int hash_7_0(string s, int max)
7.0::hash()
int hash(string s)
int hash(string s, int max)
Return an integer derived from the string s . The same string always hashes to the same value, also between processes, architectures, and Pike versions (see compatibility notes below, though).
If max is given, the result will be >= 0 and < max , otherwise the result will be >= 0 and <= 0x7fffffff.
The hash algorithm was changed in Pike 7.5. If you want a hash that is compatible with Pike 7.4 and earlier, use 7.4::hash() . The difference only affects wide strings.
The hash algorithm was also changed in Pike 7.1. If you want a hash that is compatible with Pike 7.0 and earlier, use 7.0::hash() .
7.0::hash() , 7.4::hash() , hash_value
int hash_value(mixed value)
Return a hash value for the argument. It's an integer in the native integer range.
The hash will be the same for the same value in the running process only (the memory address is typically used as the basis for the hash value).
If the value is an object with an lfun::__hash , that function is called and its result is returned.
This is the hashing method used by mappings.
hash
mixed copy_value(mixed value)
Copy a value recursively.
If the result value is changed destructively (only possible for multisets, arrays and mappings) the copied value will not be changed.
The resulting value will always be equal to the copied (as tested with the function equal() ), but they may not the the same value (as tested with `==() ).
equal()
string lower_case(string s)
int lower_case(int c)
Convert a string or character to lower case.
Returns a copy of the string s with all upper case characters converted to lower case, or the character c converted to lower case.
Assumes the string or character to be coded according to ISO-10646 (aka Unicode). If they are not, Locale.Charset.decoder can do the initial conversion for you.
Prior to Pike 7.5 this function only accepted strings.
upper_case() , Locale.Charset.decoder
string upper_case(string s)
int upper_case(int c)
Convert a string or character to upper case.
Returns a copy of the string s with all lower case characters converted to upper case, or the character c converted to upper case.
Assumes the string or character to be coded according to ISO-10646 (aka Unicode). If they are not, Locale.Charset.decoder can do the initial conversion for you.
Prior to Pike 7.5 this function only accepted strings.
lower_case() , Locale.Charset.decoder
string random_string(int len)
Returns a string of random characters 0-255 with the length len .
void random_seed(int seed)
This function sets the initial value for the random generator.
random()
int query_num_arg()
Returns the number of arguments given when the previous function was called.
This is useful for functions that take a variable number of arguments.
call_function()
int search(string haystack, string|int needle, int|void start)
int search(array haystack, mixed needle, int|void start)
mixed search(mapping haystack, mixed needle, mixed|void start)
mixed search(object haystack, mixed needle, mixed|void start)
Search for needle in haystack . Return the position of needle in
haystack or -1 if not found.
If the optional argument start is present search is started at this position.
haystack can have any of the following types:
|
If start is supplied to an iterator object without an lfun::_search() , haystack will need to implement Iterator()->set_index() .
For mappings and object UNDEFINED will be returned when not found.
In all other cases -1 will be returned when not found.
indices() , values() , zero_type()
int has_prefix(string s, string prefix)
Returns 1 if the string s starts with prefix ,
returns 0 (zero) otherwise.
int has_suffix(string s, string suffix)
Returns 1 if the string s ends with suffix ,
returns 0 (zero) otherwise.
int has_index(string haystack, int index)
int has_index(array haystack, int index)
int has_index(mapping|multiset|object|program haystack, mixed index)
Search for index in haystack .
Returns 1 if index is in the index domain of haystack ,
or 0 (zero) if not found.
This function is equivalent to (but sometimes faster than):
search(indices(haystack), index) != -1
A negative index in strings and arrays as recognized by the
index operators `[]() and `[]=() is not considered
a proper index by has_index()
has_value() , indices() , search() , values() , zero_type()
int has_value(string haystack, string value)
int has_value(string haystack, int value)
int has_value(array|mapping|object|program haystack, mixed value)
Search for value in haystack .
Returns 1 if value is in the value domain of haystack ,
or 0 (zero) if not found.
This function is in all cases except when both arguments are strings equivalent to (but sometimes faster than):
search(values(haystack ), value ) != -1
If both arguments are strings, has_value() is equivalent to:
search(haystack , value ) != -1
has_index() , indices() , search() , values() , zero_type()
void add_constant(string name, mixed value)
void add_constant(string name)
Add a new predefined constant.
This function is often used to add builtin functions. All programs compiled after the add_constant() function has been called can access value by the name name .
If there is a constant called name already, it will be replaced by by the new definition. This will not affect already compiled programs.
Calling add_constant() without a value will remove that name from the list of constants. As with replacing, this will not affect already compiled programs.
all_constants()
string combine_path(string path, string ... paths)
string combine_path_unix(string path, string ... paths)
string combine_path_nt(string path, string ... paths)
string combine_path_amigaos(string path, string ... paths)
Concatenate a number of paths to a straightforward path without
any "//", "/.." or "/.". If any path
argument is absolute then the result is absolute and the
preceding arguments are ignored. If the result is relative then
it might have leading ".." components. If the last
nonempty argument ends with a directory separator then the
result ends with that too. If all components in a relative path
disappear due to subsequent ".." components then the
result is ".".
combine_path_unix() concatenates in UNIX style, which also is appropriate for e.g. URL:s ("/" separates path components and absolute paths start with "/"). combine_path_nt() concatenates according to NT filesystem conventions ("/" and "\" separates path components and there might be a drive letter in front of absolute paths). combine_path_amigaos() concatenates according to AmigaOS filesystem conventions.
combine_path() is equivalent to combine_path_unix() on UNIX-like operating systems, and equivalent to combine_path_nt() on NT-like operating systems, and equivalent to combine_path_amigaos() on AmigaOS-like operating systems.
getcwd() , Stdio.append_path()
int zero_type(mixed a)
Return the type of zero.
There are many types of zeros out there, or at least there are two. One is returned by normal functions, and one returned by mapping lookups and find_call_out() when what you looked for wasn't there. The only way to separate these two kinds of zeros is zero_type() .
When doing a find_call_out() or mapping lookup, zero_type() on
this value will return 1 if there was no such thing present in
the mapping, or if no such call_out could be found.
If the argument to zero_type() is a destructed object or a function
in a destructed object, 2 will be returned.
In all other cases zero_type() will return 0 (zero).
find_call_out()
string string_to_unicode(string s)
Converts a string into an UTF16 compliant byte-stream.
Throws an error if characters not legal in an UTF16 stream are encountered. Valid characters are in the range 0x00000 - 0x10ffff, except for characters 0xfffe and 0xffff.
Characters in range 0x010000 - 0x10ffff are encoded using surrogates.
Locale.Charset.decoder() , string_to_utf8() , unicode_to_string() , utf8_to_string()
string unicode_to_string(string s)
Converts an UTF16 byte-stream into a string.
This function did not decode surrogates in Pike 7.2 and earlier.
Locale.Charset.decoder() , string_to_unicode() , string_to_utf8() , utf8_to_string()
string string_to_utf8(string s)
string string_to_utf8(string s, int extended)
Converts a string into an UTF-8 compliant byte-stream.
Throws an error if characters not valid in an UTF-8 stream are
encountered. Valid characters are in the ranges
0x00000000-0x0000d7ff and 0x0000e000-0x0010ffff.
If extended is 1 then characters outside the valid ranges are accepted too and encoded using the same algorithm. Such encoded characters are however not UTF-8 compliant.
Locale.Charset.encoder() , string_to_unicode() , unicode_to_string() , utf8_to_string()
string utf8_to_string(string s)
string utf8_to_string(string s, int extended)
Converts an UTF-8 byte-stream into a string.
Throws an error if the stream is not a legal UTF-8 byte-stream.
Accepts and decodes the extension used by string_to_utf8() if
extended is 1.
In conformance with RFC 3629 and Unicode 3.1 and later, non-shortest forms are not decoded. An error is thrown instead.
Locale.Charset.encoder() , string_to_unicode() , string_to_utf8() , unicode_to_string()
string __parse_pike_type(string t)
type(mixed) __soft_cast(type(mixed) to, type(mixed) from)
Return the resulting type from a soft cast of from to to .
type(mixed) __low_check_call(type(mixed) fun_type, type(mixed) arg_type)
type(mixed) __low_check_call(type(mixed) fun_type, type(mixed) arg_type, int flags)
Check whether a function of type fun_type may be called with a first argument of type arg_type .
The following flags are currently defined:
|
Returns a continuation type on success.
Returns 0 (zero) on failure.
type(mixed) __get_return_type(type(mixed) fun_type)
Check what a function of the type fun_type will return if called with no arguments.
Returns the type of the returned value on success
Returns 0 (zero) on failure.
type(mixed) __get_first_arg_type(type(mixed) fun_type)
Check if a function of the type fun_type may be called with an argument, and return the type of that argument.
Returns the expected type of the first argument to the function.
Returns 0 (zero) if a function of the type fun_type may not be called with any argument, or if it is not callable.
mapping(string:mixed) all_constants()
Returns a mapping containing all global constants, indexed on the name of the constant, and with the value of the constant as value.
add_constant()
CompilationHandler get_active_compilation_handler()
Returns the currently active compilation compatibility handler, or 0 (zero) if none is active.
This function should only be used during a call of compile() .
get_active_error_handler() , compile() , master()->get_compilation_handler() , CompilationHandler
CompilationHandler get_active_error_handler()
Returns the currently active compilation error handler (second argument to compile() ), or 0 (zero) if none is active.
This function should only be used during a call of compile() .
get_active_compilation_handler() , compile() , CompilationHandler
array allocate(int size)
array allocate(int size, mixed init)
Allocate an array of size elements. If init is specified then each element is initialized by copying that value recursively.
sizeof() , aggregate() , arrayp()
object this_object(void|int level)
Returns the object we are currently evaluating in.
level might be used to access the object of a surrounding class: The object at level 0 is the current object, the object at level 1 is the one belonging to the class that surrounds the class that the object comes from, and so on.
As opposed to a qualified this reference such as
global::this, this function doesn't always access the
objects belonging to the lexically surrounding classes. If the
class containing the call has been inherited then the objects
surrounding the inheriting class are accessed.
mixed|void throw(mixed value)
Throw value to a waiting catch .
If no catch is waiting the global error handling will send the value to master()->handle_error() .
If you throw an array with where the first index contains an error message and the second index is a backtrace, (the output from backtrace() ) then it will be treated exactly like a real error by overlying functions.
catch
void exit(int returncode, void|string fmt, mixed ... extra)
Exit the whole Pike program with the given returncode .
Using exit() with any other value than 0 (zero) indicates
that something went wrong during execution. See your system manuals
for more information about return codes.
The arguments after the returncode will be used for a call to werror to output a message on stderr.
_exit()
void _exit(int returncode)
This function does the same as exit , but doesn't bother to clean up the Pike interpreter before exiting. This means that no destructors will be called, caches will not be flushed, file locks might not be released, and databases might not be closed properly.
Use with extreme caution.
exit()
int time()
int time(int(1..1) one)
float time(int(2..) t)
This function returns the number of seconds since 00:00:00 UTC, 1 Jan 1970.
The second syntax does not query the system for the current time. Instead the latest done by the pike process is returned again. That's slightly faster but can be wildly inaccurate. Pike queries the time internally when a thread has waited for something, typically in sleep or in a backend (see Pike.Backend ).
The third syntax can be used to measure time more preciely than one second. It return how many seconds has passed since t . The precision of this function varies from system to system.
ctime() , localtime() , mktime() , gmtime() , System.gettimeofday , gethrtime
string crypt(string password)
int(0..1) crypt(string typed_password, string crypted_password)
This function crypts and verifies a short string (only the first 8 characters are significant).
The first syntax crypts the string password into something that is hopefully hard to decrypt.
The second syntax is used to verify typed_password against
crypted_password , and returns 1 if they match, and
0 (zero) otherwise.
Note that strings containing null characters will only be processed up until the null character.
void destruct(void|object o)
Mark an object as destructed.
Calls o->destroy(), and then clears all variables in the
object. If no argument is given, the current object is destructed.
All pointers and function pointers to this object will become zero. The destructed object will be freed from memory as soon as possible.
array indices(string|array|mapping|multiset|object x)
Return an array of all valid indices for the value x .
For strings and arrays this is simply an array of ascending numbers.
For mappings and multisets, the array might contain any value.
For objects which define lfun::_indices() that return value is used.
For other objects an array with all non-protected symbols is returned.
values()
array values(string|array|mapping|multiset|object x)
Return an array of all possible values from indexing the value x .
For strings an array of int with the ISO10646 codes of the characters in the string is returned.
For a multiset an array filled with ones (1) is
returned.
For arrays a single-level copy of x is returned.
For mappings the array may contain any value.
For objects which define lfun::_values() that return value is used.
For other objects an array with the values of all non-protected symbols is returned.
indices()
object next_object(object o)
object next_object()
Returns the next object from the list of all objects.
All objects are stored in a linked list.
If no arguments have been given next_object() will return the first object from the list.
If o has been specified the object after o on the list will be returned.
This function is not recomended to use.
destruct()
program|function object_program(mixed o)
Return the program from which o was instantiated. If the object was instantiated from a class using parent references the generating function will be returned.
If o is not an object or has been destructed 0 (zero)
will be returned.
string reverse(string s, int|void start, int|void end)
array reverse(array a, int|void start, int|void end)
int reverse(int i, int|void start, int|void end)
Reverses a string, array or int.
String to reverse.
Array to reverse.
Integer to reverse.
Optional start index of the range to reverse.
Default: 0 (zero).
Optional end index of the range to reverse.
Default for strings: sizeof(s)-1.
Default for arrays: sizeof(a)-1.
Default for integers: Pike.get_runtime_info()->int_size - 1.
This function reverses a string, char by char, an array, value by value or an int, bit by bit and returns the result. It's not destructive on the input value.
Reversing strings can be particularly useful for parsing difficult syntaxes which require scanning backwards.
sscanf()
string replace(string s, string from, string to)
string replace(string s, array(string) from, array(string) to)
string replace(string s, array(string) from, string to)
string replace(string s, mapping(string:string) replacements)
array replace(array a, mixed from, mixed to)
mapping replace(mapping a, mixed from, mixed to)
Generic replace function.
This function can do several kinds replacement operations, the different syntaxes do different things as follows:
If all the arguments are strings, a copy of s with every occurrence of from replaced with to will be returned. Special case: to will be inserted between every character in s if from is the empty string.
If the first argument is a string, and the others array(string), a string
with every occurrance of from [i] in s replaced with
to [i] will be returned. Instead of the arrays from and to
a mapping equvivalent to mkmapping (from , to ) can be
used.
If the first argument is an array or mapping, the values of a which are `==() with from will be replaced with to destructively. a will then be returned.
Note that replace() on arrays and mappings is a destructive operation.
program compile(string source, CompilationHandler|void handler, int|void major, int|void minor, program|void target, object|void placeholder)
Compile a string to a program.
This function takes a piece of Pike code as a string and compiles it into a clonable program.
The optional argument handler is used to specify an alternative error handler. If it is not specified the current master object will be used.
The optional arguments major and minor are used to tell the compiler to attempt to be compatible with Pike major .minor .
Note that source must contain the complete source for a program. It is not possible to compile a single expression or statement.
Also note that compile() does not preprocess the program. To preprocess the program you can use compile_string() or call the preprocessor manually by calling cpp() .
compile_string() , compile_file() , cpp() , master() , CompilationHandler , DefaultCompilerEnvironment
array|mapping|multiset set_weak_flag(array|mapping|multiset m, int state)
Set the value m to use weak or normal references in its
indices and/or values (whatever is applicable). state is a
bitfield built by using | between the following flags:
|
If a flag is absent, the corresponding field will use normal
references. state can also be 1 as a compatibility
measure; it's treated like Pike.WEAK .
m will be returned.
int objectp(mixed arg)
Returns 1 if arg is an object, 0 (zero) otherwise.
mappingp() , programp() , arrayp() , stringp() , functionp() , multisetp() , floatp() , intp()
int functionp(mixed arg)
Returns 1 if arg is a function, 0 (zero) otherwise.
mappingp() , programp() , arrayp() , stringp() , objectp() , multisetp() , floatp() , intp()
int callablep(mixed arg)
Returns 1 if arg is a callable, 0 (zero) otherwise.
mappingp() , programp() , arrayp() , stringp() , objectp() , multisetp() , floatp() , intp()
void sleep(int|float s, void|int abort_on_signal)
This function makes the program stop for s seconds.
Only signal handlers can interrupt the sleep, and only when abort_on_signal is set. If more than one thread is running the signal must be sent to the sleeping thread. Other callbacks are not called during sleep.
If s is zero then this thread will yield to other threads but not sleep otherwise. Note that Pike yields internally at regular intervals so it's normally not necessary to do this.
signal() , delay()
void delay(int|float s)
This function makes the program stop for s seconds.
Only signal handlers can interrupt the sleep. Other callbacks are not called during delay. Beware that this function uses busy-waiting to achieve the highest possible accuracy.
signal() , sleep()
int gc()
Force garbage collection.
This function checks all the memory for cyclic structures such as arrays containing themselves and frees them if appropriate. It also frees up destructed objects and things with only weak references.
Normally there is no need to call this function since Pike will call it by itself every now and then. (Pike will try to predict when 20% of all arrays/object/programs in memory is 'garbage' and call this routine then.)
The amount of garbage is returned. This is the number of arrays, mappings, multisets, objects and programs that had no nonweak external references during the garbage collection. It's normally the same as the number of freed things, but there might be some difference since destroy() functions are called during freeing, which can cause more things to be freed or allocated.
Pike.gc_parameters , Debug.gc_status
int undefinedp(mixed arg)
Returns 1 if arg is undefined, 0 (zero) otherwise.
zero_type , destructedp , intp
int destructedp(mixed arg)
Returns 1 if arg is a destructed object, 0
(zero) otherwise.
zero_type , undefinedp , intp
int programp(mixed arg)
Returns 1 if arg is a program, 0 (zero) otherwise.
mappingp() , intp() , arrayp() , stringp() , objectp() , multisetp() , floatp() , functionp()
int intp(mixed arg)
Returns 1 if arg is an int, 0 (zero) otherwise.
mappingp() , programp() , arrayp() , stringp() , objectp() , multisetp() , floatp() , functionp()
int mappingp(mixed arg)
Returns 1 if arg is a mapping, 0 (zero) otherwise.
intp() , programp() , arrayp() , stringp() , objectp() , multisetp() , floatp() , functionp()
int arrayp(mixed arg)
Returns 1 if arg is an array, 0 (zero) otherwise.
intp() , programp() , mappingp() , stringp() , objectp() , multisetp() , floatp() , functionp()
int multisetp(mixed arg)
Returns 1 if arg is a multiset, 0 (zero) otherwise.
intp() , programp() , arrayp() , stringp() , objectp() , mappingp() , floatp() , functionp()
int stringp(mixed arg)
Returns 1 if arg is a string, 0 (zero) otherwise.
intp() , programp() , arrayp() , multisetp() , objectp() , mappingp() , floatp() , functionp()
int floatp(mixed arg)
Returns 1 if arg is a float, 0 (zero) otherwise.
intp() , programp() , arrayp() , multisetp() , objectp() , mappingp() , stringp() , functionp()
array sort(array(mixed) index, array(mixed) ... data)
Sort arrays destructively.
This function sorts the array index destructively. That means that the array itself is changed and returned, no copy is created.
If extra arguments are given, they are supposed to be arrays of the same size as index . Each of these arrays will be modified in the same way as index . I.e. if index 3 is moved to position 0 in index index 3 will be moved to position 0 in all the other arrays as well.
The sort order is as follows:
Integers and floats are sorted in ascending order.
Strings are sorted primarily on the first characters that are different, and secondarily with shorter strings before longer. Different characters are sorted in ascending order on the character value. Thus the sort order is not locale dependent.
Arrays are sorted recursively on the first element. Empty arrays are sorted before nonempty ones.
Multisets are sorted recursively on the first index. Empty multisets are sorted before nonempty ones.
Objects are sorted in ascending order according to `<() , `>() and `==() .
Other types aren't reordered.
Different types are sorted in this order: Arrays, mappings, multisets, objects, functions, programs, strings, types, integers and floats. Note however that objects can control their ordering wrt other types with `< , `> and `== , so this ordering of types only applies to objects without those functions.
The first argument is returned.
The sort is stable, i.e. elements that are compare-wise equal aren't reordered.
Array.sort_array , reverse()
array rows(mixed data, array index)
Select a set of rows from an array.
This function is en optimized equivalent to:
map(index , lambda(mixed x) { return data [x]; })
That is, it indices data on every index in the array index and returns an array with the results.
column()
void _dump_program_tables(program p)
Dumps the internal tables for the program p on stderr.
mapping(string:int) gmtime(int timestamp)
Convert seconds since 00:00:00 UTC, Jan 1, 1970 into components.
This function works like localtime() but the result is not adjusted for the local time zone.
localtime() , time() , ctime() , mktime()
mapping(string:int) localtime(int timestamp)
Convert seconds since 00:00:00 UTC, 1 Jan 1970 into components.
This function returns a mapping with the following components:
|
An error is thrown if the localtime(2) call failed on the system. It's platform dependent what time ranges that function can handle, e.g. Windows doesn't handle a negative timestamp .
Prior to Pike 7.5 the field "timezone" was sometimes not
present, and was sometimes not adjusted for daylight savings time.
Calendar , gmtime() , time() , ctime() , mktime()
int mktime(mapping(string:int) tm)
int mktime(int sec, int min, int hour, int mday, int mon, int year, int|void isdst, int|void tz)
This function converts information about date and time into an integer which contains the number of seconds since 00:00:00 UTC, Jan 1, 1970.
You can either call this function with a mapping containing the following elements:
|
Or you can just send them all on one line as the second syntax suggests.
On some operating systems (notably AIX and Win32), dates before 00:00:00 UTC, Jan 1, 1970 are not supported.
On most systems, the supported range of dates are Dec 13, 1901 20:45:52 UTC through Jan 19, 2038 03:14:07 UTC (inclusive).
time() , ctime() , localtime() , gmtime()
int(0..1) glob(string glob, string str)
array(string) glob(string glob, array(string) str)
Match strings against a glob pattern.
The glob pattern. A question sign ('?') matches any character and an asterisk ('*') matches a string of arbitrary length. All other characters only match themselves.
|
sscanf() , Regexp
mixed _next(mixed x)
Find the next object/array/mapping/multiset/program or string.
All objects, arrays, mappings, multisets, programs and strings are stored in linked lists inside Pike. This function returns the next item on the corresponding list. It is mainly meant for debugging the Pike runtime, but can also be used to control memory usage.
next_object() , _prev()
mixed _prev(mixed x)
Find the previous object/array/mapping/multiset or program.
All objects, arrays, mappings, multisets and programs are stored in linked lists inside Pike. This function returns the previous item on the corresponding list. It is mainly meant for debugging the Pike runtime, but can also be used to control memory usage.
Unlike _next() this function does not work on strings.
next_object() , _next()
int _refs(string|array|mapping|multiset|function|object|program o)
Return the number of references o has.
It is mainly meant for debugging the Pike runtime, but can also be used to control memory usage.
Note that the number of references will always be at least one since the value is located on the stack when this function is executed.
_next() , _prev()
type(mixed) _typeof(mixed x)
Return the runtime type of x .
typeof()
void replace_master(object o)
Replace the master object with o .
This will let you control many aspects of how Pike works, but beware that master.pike may be required to fill certain functions, so it is usually a good idea to have your master inherit the original master and only re-define certain functions.
FIXME: Tell how to inherit the master.
master()
object master()
Return the current master object.
May return UNDEFINED if no master has been loaded yet.
replace_master()
int gethrvtime(void|int nsec)
Return the CPU time that has been consumed by this process or thread. -1 is returned if the system couldn't determine it. The time is normally returned in microseconds, but if the optional argument nsec is nonzero it's returned in nanoseconds.
The CPU time includes both user and system time, i.e. it's approximately the same thing you would get by adding together the "utime" and "stime" fields returned by System.getrusage (but perhaps with better accuracy).
It's however system dependent whether or not it's the time consumed in all threads or in the current one only; System.CPU_TIME_IS_THREAD_LOCAL tells which. If both types are available then thread local time is preferred.
The actual accuracy on many systems is significantly less than microseconds or nanoseconds. See System.CPU_TIME_RESOLUTION .
The garbage collector might run automatically at any time. The time it takes is not included in the figure returned by this function, so that normal measurements aren't randomly clobbered by it. Explicit calls to gc are still included, though.
The special function gauge is implemented with this function.
System.CPU_TIME_IS_THREAD_LOCAL , System.CPU_TIME_RESOLUTION , gauge() , System.getrusage() , gethrtime()
int gethrtime(void|int nsec)
Return the high resolution real time since some arbitrary event in the past. The time is normally returned in microseconds, but if the optional argument nsec is nonzero it's returned in nanoseconds.
It's system dependent whether or not this time is monotonic, i.e. if it's unaffected by adjustments of the calendaric clock in the system. System.REAL_TIME_IS_MONOTONIC tells what it is. Pike tries to use monotonic time for this function if it's avaiable.
The actual accuracy on many systems is significantly less than microseconds or nanoseconds. See System.REAL_TIME_RESOLUTION .
System.REAL_TIME_IS_MONOTONIC , System.REAL_TIME_RESOLUTION , time() , System.gettimeofday() , gethrvtime()
array(int|mapping(string:array(int))) get_profiling_info(program prog)
Get profiling information.
Returns an array with two elements.
| |||||||||||||||
This function is only available if the runtime was compiled with the option --with-profiling.
int(0..1) object_variablep(object o, string var)
Find out if an object identifier is a variable.
This function returns 1 if var exists as a
non-protected variable in o , and returns 0 (zero)
otherwise.
indices() , values()
mixed map(mixed arr, void|mixed fun, mixed ... extra)
Applies fun to the elements in arr and collects the results.
arr is treated as a set of elements, as follows:
fun is applied in order to each element. The results are collected, also in order, to a value of the same type as arr , which is returned.
fun is applied to the values, and each result is assigned to the same index in a new mapping, which is returned.
The program is treated as a mapping containing the identifiers that are indexable from it and their values.
If there is a lfun::cast method in the object, it's called to try to cast the object to an array, a mapping, or a multiset, in that order, which is then handled as described above.
fun is applied in different ways depending on its type:
fun is called for each element. It gets the current element as the first argument and extra as the rest. The result of the call is collected.
fun is used as a function like above, i.e. the lfun::`() method in it is called.
fun is indexed with each element. The result of that is collected.
Each element that is callable is called with extra as arguments. The result of the calls are collected. Elements that aren't callable gets zero as result.
Each element is indexed with the given string. If the result of that is zero then a zero is collected, otherwise it's called with extra as arguments and the result of that call is collected.
This is typically used when arr is a collection of objects, and fun is the name of some function in them.
The function is never destructive on arr .
filter() , enumerate() , foreach()
mixed filter(mixed arr, void|mixed fun, mixed ... extra)
Filters the elements in arr through fun .
arr is treated as a set of elements to be filtered, as follows:
Each element is filtered with fun . The return value is of the same type as arr and it contains the elements that fun accepted. fun is applied in order to each element, and that order is retained between the kept elements.
If fun is an array, it should have the same length as arr . In this case, the elements in arr are kept where the corresponding positions in fun are nonzero. Otherwise fun is used as described below.
The values are filtered with fun , and the index/value pairs it accepts are kept in the returned mapping.
The program is treated as a mapping containing the identifiers that are indexable from it and their values.
If there is a lfun::cast method in the object, it's called to try to cast the object to an array, a mapping, or a multiset, in that order, which is then filtered as described above.
Unless something else is mentioned above, fun is used as filter like this:
fun is called for each element. It gets the current element as the first argument and extra as the rest. The element is kept if it returns true, otherwise it's filtered out.
The object is used as a function like above, i.e. the lfun::`() method in it is called.
fun is indexed with each element. The element is kept if the result is nonzero, otherwise it's filtered out.
Each element that is callable is called with extra as arguments. The element is kept if the result of the call is nonzero, otherwise it's filtered out. Elements that aren't callable are also filtered out.
Each element is indexed with the given string. If the result of that is zero then the element is filtered out, otherwise the result is called with extra as arguments. The element is kept if the return value is nonzero, otherwise it's filtered out.
This is typically used when arr is a collection of objects, and fun is the name of some predicate function in them.
The function is never destructive on arr .
map() , foreach()
array(int) enumerate(int n)
array enumerate(int n, void|mixed step, void|mixed start, void|function operator)
Create an array with an enumeration, useful for initializing arrays or as first argument to map() or foreach() .
The defaults are: step = 1, start = 0, operator = `+
map() , foreach()
void error(sprintf_format f, sprintf_args ... args)
Throws an error. A more readable version of the code
throw( ({ sprintf(f, @args), backtrace() }) ).
int is_absolute_path(string p)
Check if a path p is fully qualified (ie not relative).
Returns 1 if the path is absolute, 0 otherwise.
array(string) explode_path(string p)
Split a path p into its components.
This function divides a path into its components. This might seem like it could be done by dividing the string on <tt>"/"</tt>, but that will not work on some operating systems. To turn the components back into a path again, use combine_path() .
string dirname(string x)
Returns all but the last segment of a path. Some example inputs and outputs:
|
basename() , explode_path()
string basename(string x)
Returns the last segment of a path.
dirname() , explode_path()
program compile_string(string source, void|string filename, object|void handler, void|program p, void|object o, void|int _show_if_constant_errors)
Compile the Pike code in the string source into a program.
If filename is not specified, it will default to "-".
Functionally equal to compile (cpp (source , filename )).
compile() , cpp() , compile_file()
program compile_file(string filename, object|void handler, void|program p, void|object o)
Compile the Pike code contained in the file filename into a program.
This function will compile the file filename to a Pike program that can
later be instantiated. It is the same as doing
compile_string (Stdio.read_file (filename ), filename ).
compile() , compile_string() , cpp()
string normalize_path(string path)
Replaces "\" with "/" if runing on MS Windows. It is adviced to use System.normalize_path instead.
int strlen(string|multiset|array|mapping|object thing)
Alias for sizeof .
int write(string fmt, mixed ... args)
Writes a string on stdout. Works just like Stdio.File.write on Stdio.stdout .
int werror(string fmt, mixed ... args)
Writes a string on stderr. Works just like Stdio.File.write on Stdio.stderr .
string describe_backtrace(mixed trace, void|int linewidth)
Return a readable message that describes where the backtrace trace was made (by backtrace ).
It may also be an error object or array (typically caught by a catch ), in which case the error message also is included in the description.
backtrace() , describe_error() , catch() , throw()
string describe_error(mixed err)
Return the error message from an error object or array (typically
caught by a catch ). The type of the error is checked, hence
err is declared as mixed and not object|array.
If an error message couldn't be obtained, a fallback message describing the failure is returned. No errors due to incorrectness in err are thrown.
describe_backtrace() , get_backtrace
array get_backtrace(object|array err)
Return the backtrace array from an error object or array (typically caught by a catch ), or zero if there is none. Errors are thrown on if there are problems retrieving the backtrace.
describe_backtrace() , describe_error()
| CLASS FacetGroup |
This class is used to handle facets in the system. All facets in the system have to belong to a facet group. The facet group is a pike module that inherits from this class. For example you can create a file MyFacetgroup.pmod with the following content:
inherit FacetGroup;
You can then use the facet group MyFacetGroup in a facet-class like this:
class A
{
facet NameOfMyFacet : .MyFacetGroup;
// Rest of class A
}
| CLASS MasterObject |
Master control program for Pike.
predef::master() , predef::replace_master()
object cast_to_object(string str, string|void current_file)
Called by the Pike runtime to cast strings to objects.
String to cast to object.
Filename of the file that attempts to perform the cast.
Returns the resulting object.
cast_to_program()
program cast_to_program(string str, string|void current_file)
Called by the Pike runtime to cast strings to programs.
String to cast to object.
Filename of the file that attempts to perform the cast.
Returns the resulting program.
cast_to_object()
inherit Codec : Codec
The master object is used as a fallback codec by encode_value() and decode_value() if no codec was given.
It will also be used as a codec if decode_value() encounters old-style encode_value() 'ed data.
void unregister(program p)
Unregister a program that was only partially compiled.
Called by compile() to clean up references to partially compiled programs.
Partially compiled program that should no longer be referenced.
Shouldn't this function be in the compilation handler?
void handle_error(mixed exception)
Called by the Pike runtime if an exception isn't caught.
Value that was throw() 'n.
describe_backtrace()
inherit CompilationHandler : CompilationHandler
The master object acts as fallback compilation handler for compile() and cpp() .
CompilationHandler get_compilation_handler(int major, int minor)
Get compilation handler for simulation of Pike vmajor .minor .
This function is called by cpp() when it encounters
#pike directives.
Major version.
Minor version.
Returns a compilation handler for Pike >= major .minor .
string decode_charset(string raw, string charset)
Convert raw from encoding charset to UNICODE.
This function is called by cpp() when it encounters
#charset directives.
String to convert.
Name of encoding that raw uses.
raw decoded to UNICODE, or 0 (zero) if the decoding failed.
Locale.Charset
string describe_backtrace(mixed exception)
Called by various routines to format a readable description of an exception.
Something that was thrown. Usually an Error.Generic object, or an array with the following content:
| ||||||
Returns a string describing the exeception.
Usually added by the initialization code the global name space with add_constant() .
predef::describe_backtrace()
void runtime_warning(string subsystem, string msg, mixed|void data)
Called by the Pike runtime to warn about data inconsistencies.
Runtime subsystem where the warning was generated. Currently the following subsystems may call this function:
|
Warning message. Currently the following messages may be generated:
|
Optional data that further describes the warning specified by msg .
inherit CompatResolver : CompatResolver
inherit Codec : Codec
constant MasterObject.bt_max_string_len
This constant contains the maximum length of a function entry in a backtrace. Defaults to 200 if no BT_MAX_STRING_LEN define has been given.
constant MasterObject.out_of_date_warning
Should Pike complain about out of date compiled files. 1 means yes and 0 means no. Controlled by the OUT_OF_DATE_WARNING define.
int MasterObject.want_warnings
If not zero compilation warnings will be written out on stderr.
int MasterObject.compat_major
int MasterObject.compat_minor
int MasterObject.show_if_constant_errors
inherit Pike_7_6_master : Pike_7_6_master
Namespaces for compat masters.
This inherit is used to provide compatibility namespaces for get_compat_master() .
get_compat_master()
void error(sprintf_format f, sprintf_args ... args)
Throws an error. A more readable version of the code
throw( ({ sprintf(f, @args), backtrace() }) ).
int is_absolute_path(string p)
Check if a path p is fully qualified (ie not relative).
Returns 1 if the path is absolute, 0 otherwise.
array(string) explode_path(string p)
Split a path p into its components.
This function divides a path into its components. This might seem like it could be done by dividing the string on <tt>"/"</tt>, but that will not work on some operating systems. To turn the components back into a path again, use combine_path() .
string dirname(string x)
Returns all but the last segment of a path. Some example inputs and outputs:
|
basename() , explode_path()
string basename(string x)
Returns the last segment of a path.
dirname() , explode_path()
program compile_string(string source, void|string filename, object|void handler, void|program p, void|object o, void|int _show_if_constant_errors)
Compile the Pike code in the string source into a program.
If filename is not specified, it will default to "-".
Functionally equal to compile (cpp (source , filename )).
compile() , cpp() , compile_file()
string master_read_file(string file)
string getenv(string varname, void|int force_update)
mapping(string:string) getenv(void|int force_update)
Queries the environment variables. The first variant returns the value of a specific variable or zero if it doesn't exist in the environment. The second variant returns the whole environment as a mapping. Destructive operations on the mapping will not affect the internal environment representation.
A cached copy of the real environment is kept to make this function quicker. If the optional flag force_update is nonzero then the real environment is queried and the cache is updated from it. That can be necessary if the environment changes through other means than putenv , typically from a C-level library.
Variable names and values cannot be wide strings nor contain
'\0' characters. Variable names also cannot contain
'=' characters.
On NT the environment variable name is case insensitive.
putenv()
void putenv(string varname, void|string value)
Sets the environment variable varname to value .
If value is omitted or zero, the environment variable varname is removed.
varname and value cannot be wide strings nor contain
'\0' characters. varname also cannot contain
'=' characters.
On NT the environment variable name is case insensitive.
getenv()
program compile_file(string filename, object|void handler, void|program p, void|object o)
Compile the Pike code contained in the file filename into a program.
This function will compile the file filename to a Pike program that can
later be instantiated. It is the same as doing
compile_string (Stdio.read_file (filename ), filename ).
compile() , compile_string() , cpp()
string normalize_path(string path)
Replaces "\" with "/" if runing on MS Windows. It is adviced to use System.normalize_path instead.
mapping(string:program|NoValue) MasterObject.programs
mapping(program:object) MasterObject.documentation
mapping(program:string) MasterObject.source_cache
Mapping containing the cache of currently compiled files.
This mapping currently has the following structure:
|
The filename path separator is / on both NT and UNIX.
Special cases: The current master program is available under the
name "/master", and the program containing the main
function under "/main".
string programs_reverse_lookup(program prog)
Returns the path for prog in programs , if it got any.
program objects_reverse_lookup(object obj)
Returns the program for obj , if known to the master.
string fc_reverse_lookup(object obj)
Returns the path for obj in fc , if it got any.
array(string) module_defined(object|program mod)
Find the files in which mod is defined, as they may be hidden away in joinnodes and dirnodes
The module we are looking for.
An array of strings with filenames. (one for each file in a joinnode, or just one otherwise)
void enable_source_cache()
Enable caching of sources from compile_string()
object show_doc(program|object|function obj)
Show documentation for the item obj
The object for which the documentation should be shown
an AutoDoc object
program cast_to_program(string pname, string current_file, object|void handler)
This function is called when the driver wants to cast a string to a program, this might be because of an explicit cast, an inherit or a implict cast. In the future it might receive more arguments, to aid the master finding the right program.
void handle_error(array|object trace)
This function is called when an error occurs that is not caught with catch().
string MasterObject.include_prefix
Prefix for Pike-related C header files.
string MasterObject.doc_prefix
Prefix for autodoc files.
string MasterObject.cflags
Flags suitable for use when compiling Pike C modules
string MasterObject.ldflags
Flags suitable for use when linking Pike C modules
int strlen(string|multiset|array|mapping|object thing)
Alias for sizeof .
int write(string fmt, mixed ... args)
Writes a string on stdout. Works just like Stdio.File.write on Stdio.stdout .
int werror(string fmt, mixed ... args)
Writes a string on stderr. Works just like Stdio.File.write on Stdio.stderr .
program handle_inherit(string pname, string current_file, object|void handler)
This function is called whenever a inherit is called for. It is supposed to return the program to inherit. The first argument is the argument given to inherit, and the second is the file name of the program currently compiling. Note that the file name can be changed with #line, or set by compile_string, so it can not be 100% trusted to be a filename. previous_object(), can be virtually anything in this function, as it is called from the compiler.
object cast_to_object(string oname, string current_file, object|void current_handler)
This function is called when the drivers wants to cast a string to an object because of an implict or explicit cast. This function may also receive more arguments in the future.
string MasterObject._pike_file_name
string MasterObject._master_file_name
These are useful if you want to start other Pike processes with the same options as this one was started with.
int(0..1) asyncp()
Returns 1 if we´re in async-mode, e.g. if the main method has returned a negative number.
object backend_thread()
The backend_thread() function is useful to determine if you are the backend thread - important when doing async/sync protocols. This method is only available if thread_create is present.
void _main(array(string) orig_argv)
This function is called when all the driver is done with all setup of modules, efuns, tables etc. etc. and is ready to start executing _real_ programs. It receives the arguments not meant for the driver.
void compile_error(string file, int line, string err)
This function is called whenever a compile error occurs. line is zero for errors that aren't associated with any specific line. err is not newline terminated.
void compile_warning(string file, int line, string err)
This function is called whenever a compile warning occurs. line is zero for warnings that aren't associated with any specific line. err is not newline terminated.
int compile_exception(array|object trace)
This function is called when an exception is catched during compilation. Its message is also reported to compile_error if this function returns zero.
void runtime_warning(string where, string what, mixed ... args)
Called for every runtime warning. The first argument identifies where the warning comes from, the second identifies the specific message, and the rest depends on that. See code below for currently implemented warnings.
string decode_charset(string data, string charset)
This function is called by cpp() when it wants to do character code conversion.
string program_path_to_name(string path, void|string module_prefix, void|string module_suffix, void|string object_suffix)
Converts a module path on the form "Foo.pmod/Bar.pmod" or
"/path/to/pike/lib/modules/Foo.pmod/Bar.pmod" to a module
identifier on the form "Foo.Bar".
If module_prefix or module_suffix are given, they are
prepended and appended, respectively, to the returned string if
it's a module file (i.e. ends with ".pmod" or
".so"). If object_suffix is given, it's appended to the
returned string if it's an object file (i.e. ends with
".pike").
string describe_module(object|program mod, array(object)|void ret_obj)
Describe the path to the module mod .
If mod is a program, attempt to describe the path to a clone of mod .
If an instance of mod is found, it will be returned
by changing element 0 of ret_obj .
The a description of the path.
The returned description will end with a proper indexing method
currently either "." or "->".
string describe_object(object o)
string describe_program(program|function p)
string describe_function(function f)
string describe_backtrace(mixed trace, void|int linewidth)
Return a readable message that describes where the backtrace trace was made (by backtrace ).
It may also be an error object or array (typically caught by a catch ), in which case the error message also is included in the description.
backtrace() , describe_error() , catch() , throw()
string describe_error(mixed err)
Return the error message from an error object or array (typically
caught by a catch ). The type of the error is checked, hence
err is declared as mixed and not object|array.
If an error message couldn't be obtained, a fallback message describing the failure is returned. No errors due to incorrectness in err are thrown.
describe_backtrace() , get_backtrace
array get_backtrace(object|array err)
Return the backtrace array from an error object or array (typically caught by a catch ), or zero if there is none. Errors are thrown on if there are problems retrieving the backtrace.
describe_backtrace() , describe_error()
Version MasterObject.currentversion
Version information about the current Pike version.
object get_compat_master(int major, int minor)
Return a master object compatible with the specified version of Pike.
This function is used to implement the various compatibility versions of master() .
get_compilation_handler() , master()
| CLASS MasterObject.Pike_0_5_master |
Pike 0.5 master compatibility interface.
Most of the interface is implemented via mixin, or overloading by more recent masters.
This interface is used for compatibility with all pikes until Pike 0.5.
get_compat_master() , master() , predef::MasterObject
mapping(string:array(string)) MasterObject.Pike_0_5_master.environment
Mapping containing the environment variables.
The mapping currently has the following structure:
| |||||||||
This mapping should not be accessed directly; use getenv() and putenv() instead. This mapping is not publicly accessible in pikes newer than 7.6.
This mapping is not compatible with Process.create_process() ; use the mapping returned from calling getenv() without arguments instead.
This mapping is not the real environment; it is just a copy of the environment made at startup. Pike does attempt to keep track of changes in the mapping and to reflect them in the real environment, but avoid accessing this mapping if at all possible.
__deprecated__ object new(mixed prog, mixed ... args)
Make a new instance of a class.
This function should not be used. It is here for compatibility reasons only.
| CLASS MasterObject.Pike_0_6_master |
Pike 0.6 master compatibility interface.
Most of the interface is implemented via mixin, or overloading by more recent masters.
This interface is used for compatibility with Pike 0.6.
get_compat_master() , master() , predef::MasterObject
inherit Pike_0_5_master : Pike_0_5_master
| CLASS MasterObject.Pike_7_0_master |
Pike 7.0 master compatibility interface.
Most of the interface is implemented via mixin, or overloading by more recent masters.
This interface is used for compatibility with Pike 0.7 through 7.0.
get_compat_master() , master() , predef::MasterObject
inherit Pike_0_6_master : Pike_0_6_master
| CLASS MasterObject.Pike_7_2_master |
Pike 7.2 master compatibility interface.
Most of the interface is implemented via mixin, or overloading by more recent masters.
This interface is used for compatibility with Pike 7.1 and 7.2.
get_compat_master() , master() , predef::MasterObject
inherit Pike_7_0_master : Pike_7_0_master
| CLASS MasterObject.Pike_7_4_master |
Pike 7.4 master compatibility interface.
Most of the interface is implemented via mixin, or overloading by more recent masters.
This interface is used for compatibility with Pike 7.3 and 7.4.
get_compat_master() , master() , predef::MasterObject
inherit Pike_7_2_master : Pike_7_2_master
| CLASS MasterObject.Pike_7_6_master |
Pike 7.6 master compatibility interface.
Most of the interface is implemented via mixin, or overloading by more recent masters.
This interface is used for compatibility with Pike 7.5 and 7.6.
get_compat_master() , master() , predef::MasterObject
inherit Pike_7_4_master : Pike_7_4_master
| CLASS MasterObject.dirnode |
Module node representing a single directory.
joinnode
| CLASS MasterObject.joinnode |
Module node holding possibly multiple directories, and optionally falling back to another level.
dirnode
| CLASS MasterObject.CompatResolver |
Resolver of symbols not located in the program being compiled.
joinnode MasterObject.CompatResolver.root_module
Join node of the root modules for this resolver.
mapping(object:joinnode) MasterObject.CompatResolver.handler_root_modules
Lookup from handler module to corresponding root_module.
array(string) MasterObject.CompatResolver.system_module_path
The pike system module path, not including any set by the user.
array(string) MasterObject.CompatResolver.pike_module_path
The complete module search path
array(string) MasterObject.CompatResolver.pike_include_path
The complete include search path
array(string) MasterObject.CompatResolver.pike_program_path
The complete program search path
CompatResolver MasterObject.CompatResolver.fallback_resolver
If we fail to resolv, try the fallback.
Typical configuration:
0.6->7.0->7.2-> ... ->master
void MasterObject.CompatResolver(mixed version, CompatResolver|void fallback_resolver)
The CompatResolver is initialized with a value that can be casted into a "%d.%d" string, e.g. a version object.
It can also optionally be initialized with a fallback resolver.
void add_include_path(string tmp)
Add a directory to search for include files.
This is the same as the command line option -I.
Note that the added directory will only be searched when using < > to quote the included file.
remove_include_path()
void remove_include_path(string tmp)
Remove a directory to search for include files.
This function performs the reverse operation of add_include_path() .
add_include_path()
void add_module_path(string tmp)
Add a directory to search for modules.
This is the same as the command line option -M.
remove_module_path()
void remove_module_path(string tmp)
Remove a directory to search for modules.
This function performs the reverse operation of add_module_path() .
add_module_path()
void add_program_path(string tmp)
Add a directory to search for programs.
This is the same as the command line option -P.
remove_program_path()
void remove_program_path(string tmp)
Remove a directory to search for programs.
This function performs the reverse operation of add_program_path() .
add_program_path()
void add_predefine(string name, string value)
Add a define (without arguments) which will be implicitly defined in cpp calls.
void remove_predefine(string name)
Remove a define from the set that are implicitly defined in cpp calls.
mapping get_predefines()
Returns a mapping with the current predefines.
mapping(string:mixed) instantiate_static_modules(object|mapping static_modules)
Instantiate static modules in the same way that dynamic modules are instantiated.
mapping get_default_module()
mixed resolv_base(string identifier, string|void current_file, object|void current_handler)
mixed resolv_or_error(string identifier, string|void current_file, void|object current_handler)
Same as resolv , but throws an error instead of returning UNDEFINED if the resolv failed.
mixed resolv(string identifier, string|void current_file, object|void current_handler)
string handle_include(string f, string current_file, int local_include)
This function is called whenever an #include directive is encountered. It receives the argument for #include and should return the file name of the file to include
string read_include(string f)
| CLASS MasterObject.Pike06Resolver |
inherit CompatResolver : CompatResolver
mixed resolv_base(string identifier, string|void current_file, object|void current_handler)
In Pike 0.6 the current directory was implicitly searched.
| CLASS MasterObject.Encoder |
Codec for use with encode_value . It understands all the standard references to builtin functions, pike modules, and the main program script.
The format of the produced identifiers are documented here to allow extension of this class:
The produced names are either strings or arrays. The string variant specifies the thing to look up according to the first character:
'c' Look up in all_constants(). 's' Look up in _static_modules. 'r' Look up with resolv(). 'p' Look up in programs. 'o' Look up in programs, then look up the result in objects. 'f' Look up in fc.
In the array format, the first element is a string as above and the rest specify a series of things to do with the result:
A string Look up this string in the result. 'm' Get module object in dirnode. 'p' Do object_program(result).
All lowercase letters and the symbols ':', '/' and '.' are reserved for internal use in both cases where characters are used above.
string|array nameof(mixed what, void|array(object) module_object)
When module_object is set and the name would end with an
object_program step (i.e. 'p'), then drop that
step so that the name corresponds to the object instead.
module_object [0] will receive the found object.
void MasterObject.Encoder(void|mixed encoded)
Creates an encoder instance. If encoded is specified, it's encoded instead of being reverse resolved to a name. That's necessary to encode programs.
| CLASS MasterObject.Decoder |
Codec for use with decode_value . This is the decoder corresponding to Encoder . See that one for more details.
void|string MasterObject.Decoder.fname
void|int MasterObject.Decoder.mkobj
void|object MasterObject.Decoder.handlervoid MasterObject.Decoder(void|string fname, void|int mkobj, void|object handler)
array(mixed) decode_object(object o, mixed data)
Restore the state of an encoded object.
Object to modify.
State information from Encoder()->encode_object() .
The default implementation calls o->_decode(data)
if the object has an _decode(), otherwise if
data is an array, returns it to indicate that lfun::create()
should be called.
This function is called beforelfun::create() in the object has been called, but after lfun::__INIT() has been called.
Returns an array to indicate to the caller that lfun::create() should be called with the elements of the array as arguments.
Returns 0 (zero) to inhibit calling of lfun::create() .
Encoder()->encode_object()
| CLASS MasterObject.Codec |
Encoder and Decoder rolled into one. This is for mainly compatibility; there's typically no use combining encoding and decoding into the same object.
inherit Encoder : Encoder
inherit Decoder : Decoder
void MasterObject.Codec(void|mixed encoded)
The optional argument is the thing to encode; it's passed on to Encoder .
| CLASS MasterObject.Version |
Contains version information about a Pike version.
int MasterObject.Version.major
int MasterObject.Version.minor
The major and minor parts of the version.
void MasterObject.Version(int major, int minor)
Set the version in the object.
int `<(mixed v)
int `>(mixed v)
int `==(mixed v)
int __hash()
Methods define so that version objects can be compared and ordered.
mixed cast(string type)
The version object can be casted into a string.
| CLASS string_assignment |
int `[](int i)
String index operator.
int `[]=(int i, int j)
String assign index operator.
| CLASS Codec |
Codec objects are used by encode_value() and decode_value() to encode and decode objects, functions and programs.
encode_value() and decode_value() will use the current master object as fallback codec object if no codec was specified.
mixed nameof(object|function|program x)
Called by encode_value() to encode objects, functions and programs.
Returns something encodable on success, typically a string. The returned value will be passed to the corresponding objectof() , functionof() or programof() by decode_value() .
Returns UNDEFINED on failure.
encode_value() has fallbacks for some classes of objects, functions and programs.
objectof() , functionof() , objectof()
object objectof(string data)
Decode object encoded in data .
This function is called by decode_value() when it encounters encoded objects.
Encoding of some object as specified by nameof() .
Minor version.
Returns the decoded object.
functionof() , programof()
function functionof(string data)
Decode function encoded in data .
This function is called by decode_value() when it encounters encoded functions.
Encoding of some function as specified by nameof() .
Minor version.
Returns the decoded function.
objectof() , programof()
program programof(string data)
Decode program encoded in data .
This function is called by decode_value() when it encounters encoded programs.
Encoding of some program as specified by nameof() .
Minor version.
Returns the decoded program.
functionof() , objectof()
object __register_new_program(program p)
Called by decode_value() to register the program that is being decoded. Might get called repeatedly with several other programs that are being decoded recursively. The only safe assumption is that when the top level thing being decoded is a program, then the first call will be with the unfinished embryo that will later become that program.
Returns either zero or a placeholder object. A placeholder object must be a clone of __null_program . When the program is finished, the placeholder object will be converted to a clone of it. This is used for pike module objects.
| CLASS CompilationHandler |
Objects used by the compiler to handle references to global symbols, modules, external files, etc.
There can be up to three compilation handlers active at the same time during a compilation. They are in order of precedence:
The error handler
This is the object passed to compile() as the second argument (if any). This object is returned by get_active_error_handler() during a compilation.
The compatibility handler
This is the object returned by
master()->get_compilation_handler() (if any), which
the compiler calls when it sees #pike-directives,
or expressions using the version scope
(eg 7.4::rusage). This object is returned by
get_active_compilation_handler() during a compilation.
The master object.
This is returned by master() at any time.
Any of the objects may implement a subset of the CompilationHandler functions, and the first object that implements a function will be used. The error handler object can thus be used to block certain functionality (eg to restrict the number of available functions).
master()->get_compilation_handler() , get_active_error_handler() , get_active_compilation_handler() , compile()
mapping(string:mixed)|object get_default_module()
Returns the default module from which global symbols will be fetched.
Returns the default module, or 0 (zero).
If 0 (zero) is returned the compiler use the mapping
returned by all_constants() as fallback.
get_predefines()
void compile_warning(string filename, int line, string msg)
Called by compile() to report warnings.
File which triggered the warning.
Line which triggered the warning.
Warning message.
compile_error()
void compile_error(string filename, int line, string msg)
Called by compile() and cpp() when they encounter errors in the code they compile.
File where the error was detected.
Line where the error was detected.
Description of error.
compile_warning() .
void compile_exception(mixed exception)
Called by compile() and cpp() if they trigger exceptions.
mapping(string:mixed) get_predefines()
Called by cpp() to get the set of global symbols.
Returns a mapping from symbol name to symbol value. Returns zero on failure.
resolv() , get_default_module()
mixed resolv(string symbol, string filename, CompilationHandler handler)
Called by compile() and cpp() to resolv module references.
Returns the resolved value, or UNDEFINED on failure.
get_predefines()
mixed handle_import(string path, string filename, CompilationHandler handler)
Called by compile() and cpp() to handle import directives specifying specific paths.
Returns the resolved value, or UNDEFINED on failure.
string handle_include(string header_file, string current_file, int(0..1) is_local_ref)
Called by cpp() to resolv #include and #string
directives.
File that was requested for inclusion.
File where the directive was found.
Specifies reference method.
|
Returns the filename to pass to read_include() if found,
and 0 (zero) on failure.
read_include()
string read_include(string filename)
Called by cpp() to read included files.
Filename as returned by handle_include() .
Returns a string with the content of the header file on success,
and 0 (zero) on failure.
handle_include()
| CLASS CompilerEnvironment |
The compiler environment.
void report(SeverityLevel severity, string filename, int linenumber, string subsystem, string message, mixed ... extra_args)
Report a diagnostic from the compiler.
PikeCompiler()->report()
program compile(string source, CompilationHandler|void handler, int|void major, int|void minor, program|void target, object|void placeholder)
Compile a string to a program.
This function takes a piece of Pike code as a string and compiles it into a clonable program.
The optional argument handler is used to specify an alternative error handler. If it is not specified the current master object will be used.
The optional arguments major and minor are used to tell the compiler to attempt to be compatible with Pike major .minor .
This function essentially performs
program compile(mixed ... args)
{
return PikeCompiler(@args)->compile();
}
Note that source must contain the complete source for a program. It is not possible to compile a single expression or statement.
Also note that compile() does not preprocess the program. To preprocess the program you can use compile_string() or call the preprocessor manually by calling cpp() .
compile_string() , compile_file() , cpp() , master() , CompilationHandler
mixed resolv(string identifier, string filename, object|void handler)
object get_compilation_handler(int major, int minor)
Get compatibility handler for Pike major .minor .
This function is typically called by PikeCompiler()->get_compilation_handler() .
mapping(string:mixed)|object get_default_module()
Get the default module for the current compatibility level (ie typically the value returned by predef::all_constants() ).
The default implementation calls the corresponding function in the master object.
|
This function is typically called by Pike_compiler()->get_default_module() .
program handle_inherit(string inh, string current_file, object|void handler)
Look up an inherit inh .
int filter_exception(SeverityLevel level, mixed err)
| ENUM CompilerEnvironment.SeverityLevel |
Message severity level. { NOTICE, WARNING, ERROR, FATAL }
report()
constant CompilerEnvironment.NOTICE
constant CompilerEnvironment.WARNING
constant CompilerEnvironment.ERROR
constant CompilerEnvironment.FATAL
| CLASS CompilerEnvironment.PikeCompiler |
The Pike compiler.
An object of this class compiles a single string of Pike code.
void report(SeverityLevel severity, string filename, int linenumber, string subsystem, string message, mixed ... extra_args)
Report a diagnostic from the compiler.
The default implementation calls the corresponding function in the active handlers, and otherwise falls back to CompilerEnvironment()->report() in the parent object.
void CompilerEnvironment.PikeCompiler(string|void source, CompilationHandler|void handler, int|void major, int|void minor, program|void target, object|void placeholder)
Create a PikeCompiler object for a source string.
This function takes a piece of Pike code as a string and initializes a compiler object accordingly.
Source code to compile.
The optional argument handler is used to specify an alternative error handler. If it is not specified the current master object at compile time will be used.
The optional arguments major and minor are used to tell the compiler to attempt to be compatible with Pike major .minor .
__empty_program() program to fill in. The virgin program returned by __empty_program() will be modified and returned by compile() on success.
__null_program() placeholder object to fill in. The object will be modified into an instance of the resulting program on successfull compile. Note that lfun::create() in the program will be called without any arguments.
Note that source must contain the complete source for a program. It is not possible to compile a single expression or statement.
Also note that no preprocessing is performed. To preprocess the program you can use compile_string() or call the preprocessor manually by calling cpp() .
Note that all references to target and placeholder should removed if compile() failes. On failure the placeholder object will be destructed.
compile_string() , compile_file() , cpp() , master() , CompilationHandler
program compile()
Compile the current source into a program.
This function compiles the current Pike source code into a clonable program.
compile_string() , compile_file() , cpp() , master() , CompilationHandler , create()
mixed resolv(string identifier, string filename, object handler)
Resolve the symbol identifier .
The default implementation calls the corresponding function in any active handler, and otherwise falls back to CompilerEnvironment()->resolv() in the parent object.
object get_compilation_handler(int major, int minor)
Get compatibility handler for Pike major .minor .
This function is called by change_compiler_compatibility() .
mapping(string:mixed)|object get_default_module()
Get the default module for the current compatibility level (ie typically the value returned by predef::all_constants() ).
The default implementation calls the corresponding function in the current handler, the current compatibility handler or in the parent CompilerEnvironment in that order.
|
This function is called by change_compiler_compatibility() .
void change_compiler_compatibility(int major, int minor)
Change compiler to attempt to be compatible with Pike major .minor .
program handle_inherit(string inh)
Look up an inherit inh in the current program.
int(0..1) pop_type_attribute(string attribute, type(mixed) a, type(mixed) b)
Type attribute handler.
Called during type checking when a <= b and
a had the type attribute attribute before the
comparison.
The default implementation implements the "deprecated" attribute.
Returns 1 if the type check should be allowed
(ie __attribute__(attribute, a) <= b), and
0 (zero) otherwise.
push_type_attribute()
int(0..1) push_type_attribute(string attribute, type(mixed) a, type(mixed) b)
Type attribute handler.
Called during type checking when a <= b and
b had the type attribute attribute before the
comparison.
The default implementation implements the "deprecated" attribute.
Returns 1 if the type check should be allowed
(ie a <= __attribute__(attribute, b)), and
0 (zero) otherwise.
pop_type_attribute()
int(0..1) apply_type_attribute(string attribute, type(mixed) a, type(mixed)|void b)
Type attribute handler.
Attribute that a had.
Type of the value being called.
Type of the first argument in the call, or UNDEFINED if no more arguments.
Called during type checking when a has been successfully had a partial evaluation with the argument b and a had the type attribute attribute before the evaluation.
The default implementation implements the "deprecated" attribute.
Returns 1 if the type check should be allowed
(ie __attribute__(attribute, a)(b)) is valid,
and 0 (zero) otherwise.
pop_type_attribute() , push_type_attribute()
type(mixed) apply_attribute_constant(string attr, mixed value, type(mixed) arg_type, void cont_type)
Handle constant arguments to attributed function argument types.
Attribute that arg_type had.
Constant value sent as parameter.
Declared type of the function argument.
Continuation function type after the current argument.
This function is called when a function is called with the constant value value and it has been successfully matched against arg_type , and arg_type had the type attribute attr .
This function is typically used to perform specialized argument checking and to allow for a strengthening of the function type based on value .
The default implementation implements the "sprintf_format",
"sscanf_format" and "sscanf_76_format" attributes.
Returns a continuation type if it succeeded in strengthening the type.
Returns UNDEFINED otherwise (this is not an error indication).
pop_type_attribute() , push_type_attribute()
| CLASS CompilerEnvironment.PikeCompiler.CompilerState |
Keeps the state of a single program/class during compilation.
Not in use yet!
| CLASS Iterator |
This is the interface for iterator objects. They implement an interface to a collection or stream of data items and a cursor that can be used to iterate over and examine individual items in the data set.
Iterators are typically created to access a data set in some specific object, array, mapping, multiset or string. An object can have several iterators that access different data sets in it, or the same in different ways. E.g. strings have both an iterator for access char-by-char (String.Iterator ), and another for access over splitted substrings (String.SplitIterator ). lfun::_get_iterator may be defined in an object to get an instance of the canonical iterator type for it. It's used by e.g. foreach to iterate over objects conveniently.
It's not an error to advance an iterator past the beginning or end of the data set; `!() will only return true then, and index and value will return UNDEFINED . An iterator in that state need not keep track of positions, so it's undefined what happens if it's "moved back" into the set of items.
Backward movement for iterators is optional. It's supported if and only if `-() is defined, but even then it's undefined how far back the iterator can move. Therefore iterators may support only a limited amount of backward movement, e.g. when they access a stream through a limited buffer. If such an iterator is moved back past the limit then it'll behave as if it's pointing entirely outside the data set (see above).
An iterator that doesn't support backward movement at all should throw an error if it's attempted.
predef::get_iterator , lfun::_get_iterator , Array.Iterator , Mapping.Iterator , Multiset.Iterator , String.Iterator , String.SplitIterator .
void Iterator(void|mixed data)
Initialize this iterator to access a data set in data . The type of data is specific to the iterator implementation. An iterator may also access some implicit data set, in which case data isn't specified at all.
The iterator initially points to the first item in the data set, if there is any.
The iterator does not need to support being reused, so this function is typically protected.
int(0..1) `!()
Returns 0 (zero) when the iterator points to an item,
1 otherwise.
Iterator `+(int steps)
Returns a clone of this iterator which is advanced the specified number of steps. The amount may be negative to move backwards. If the iterator doesn't support backward movement it should throw an exception in that case.
Iterator `+=(int steps)
Advance this iterator the specified number of steps and return it. The amount may be negative to move backwards. If the iterator doesn't support backward movement it should throw an exception in that case.
foreach calls this function with a step value of 1
if next() doesn't exist for compatibility with Pike 7.6
and earlier.
foreach will call this function even when the the
iterator has more than one reference. If you want to
loop over a copy of the iterator, you can create a
copy by adding 0 (zero) to it:
Iterator iterator;
...
foreach(iterator+0; mixed index; mixed value) {
...
}
Even though this function is sufficient for foreach to advance the iterator, next() is the preferred API. next() has the additional advantage of not being an lfun, so it is possible to advance the iterator by hand.
Iterator `-(int steps)
This lfun should be defined if and only if the iterator supports backward movement to some degree. It should back up the specified number of steps. The amount may be negative to move forward.
mixed index()
Returns the current index, or UNDEFINED if the iterator doesn't point to any item.
If there's no obvious index set then the index is the current
position in the data set, counting from 0 (zero).
mixed value()
Returns the current value, or UNDEFINED if the iterator doesn't point to any item.
int _sizeof()
Returns the total number of items in the data set according to this iterator. If the size of the data set is unlimited or unknown then this function shouldn't be defined.
void _random()
If this function is defined then it sets the iterator to point to a random item in the accessible set. The random distribution should be rectangular within that set, and the pseudorandom sequence provided by random should be used.
int(0..1) first()
If this function is defined then it resets the iterator to point to the first item.
Returns zero if there are no items at all in the data set, one otherwise.
It's not enough to set the iterator to the earliest accessible item. If the iterator doesn't support backing up to the original start position then this function should not be implemented.
int next()
If this function is defined it should advance the iterator one
step, just like `+= (1) would do.
This is the preferred way to advance the iterator, since it reduces the overhead.
This function was optional in Pike 7.6 and earlier.
Returns 1 if it succeeded in advancing, and 0 (zero) if it has reached the end of the iterator.
void set_index(zero index)
If this function is defined it should set the iterator at the specified index.
It should be possible to set the index at the end of the iterator.
| CLASS mklibpike |
mapping(string:array(array(Parser.C.Token))) parse(array(Parser.C.Token) tokens)
Returns a mapping from symbol to a tuple of return type and parameters.
| Module Stdio |
inherit files : files
constant Stdio.TCSANOW
Argument to Stdio.File()->tcsetattr() .
Change immediately.
constant Stdio.TCSADRAIN
Argument to Stdio.File()->tcsetattr() .
Change after all output has been written.
constant Stdio.TCSAFLUSH
Argument to Stdio.File()->tcsetattr() .
Change after all output has been written, and empty the input buffers.
FILE Stdio.stderr
An instance of FILE("stderr"), the standard error stream. Use this when you want to output error messages.
predef::werror()
FILE Stdio.stdout
An instance of FILE("stdout"), the standatd output stream. Use this when you want to write anything to the standard output.
predef::write()
FILE Stdio.stdin
An instance of FILE("stdin"), the standard input stream. Use this when you want to read anything from the standard input. This example will read lines from standard input for as long as there are more lines to read. Each line will then be written to stdout together with the line number. We could use Stdio.stdout.write() instead of just write() , since they are the same function.
int main() { int line; while(string s=Stdio.stdin.gets()) write("%5d: %s\n", line++, s); }
string read_file(string filename)
string read_file(string filename, int start, int len)
Read len lines from a regular file filename after skipping start lines and return those lines as a string. If both start and len are omitted the whole file is read.
Throws an error on any I/O error except when the file doesn't exist.
Returns 0 (zero) if the file doesn't exist or if
start is beyond the end of it.
Returns a string with the requested data otherwise.
read_bytes() , write_file()
string read_bytes(string filename, int start, int len)
string read_bytes(string filename, int start)
string read_bytes(string filename)
Read len number of bytes from a regular file filename starting at byte start , and return it as a string.
If len is omitted, the rest of the file will be returned.
If start is also omitted, the entire file will be returned.
Throws an error on any I/O error except when the file doesn't exist.
Returns 0 (zero) if the file doesn't exist or if
start is beyond the end of it.
Returns a string with the requested data otherwise.
read_file , write_file() , append_file()
int write_file(string filename, string str, int|void access)
Write the string str onto the file filename . Any existing data in the file is overwritten.
For a description of access , see Stdio.File()->open() .
Throws an error if filename couldn't be opened for writing.
Returns the number of bytes written, i.e. sizeof(str).
append_file() , read_bytes() , Stdio.File()->open()
int append_file(string filename, string str, int|void access)
Append the string str onto the file filename .
For a description of access , see Stdio.File->open() .
Throws an error if filename couldn't be opened for writing.
Returns the number of bytes written, i.e. sizeof(str).
write_file() , read_bytes() , Stdio.File()->open()
int file_size(string filename)
Give the size of a file. Size -1 indicates that the file either does not exist, or that it is not readable by you. Size -2 indicates that it is a directory, -3 that it is a symlink and -4 that it is a device.
file_stat() , write_file() , read_bytes()
string append_path(string absolute, string ... relative)
string append_path_unix(string absolute, string ... relative)
string append_path_nt(string absolute, string ... relative)
Append relative paths to an absolute path and remove any
"//", "../" or "/." to produce a
straightforward absolute path as a result.
"../" is ignorded in the relative paths if it makes the
created path begin with something else than the absolute path
(or so far created path).
append_path_nt() fixes drive letter issues in relative
by removing the colon separator ":" if it exists (k:/fnord appends
as k/fnord)
append_path_nt() also makes sure that UNC path(s) in relative is appended
correctly by removing any "\\" or "//" from the beginning.
append_path() is equivalent to append_path_unix() on UNIX-like operating systems, and equivalent to append_path_nt() on NT-like operating systems.
combine_path()
string simplify_path(string path)
Returns a canonic representation of path (without /./, /../, // and similar path segments).
void perror(string s)
This function prints a message to stderr along with a description of what went wrong if available. It uses the system errno to find out what went wrong, so it is only applicable to IO errors.
werror()
int is_file(string path)
Check if a path is a file.
Returns true if the given path is a file, otherwise false.
exist() , is_dir() , is_link() , file_stat()
int is_dir(string path)
Check if a path is a directory.
Returns true if the given path is a directory, otherwise false.
exist() , is_file() , is_link() , file_stat()
int is_link(string path)
Check if a path is a symbolic link.
Returns true if the given path is a symbolic link, otherwise false.
exist() , is_dir() , is_file() , file_stat()
int exist(string path)
Check if a path exists.
Returns true if the given path exists (is a directory or file), otherwise false.
May fail with eg errno() EFBIG if the file exists, but the filesystem doesn't support the file size.
is_dir() , is_file() , is_link() , file_stat()
int convert_modestring2int(string mode_string)
Convert the mode_string string as returned by Stdio.Stat object to int suitable for chmod
The string as return from Stdio.Stat()->mode_string
An int matching the permission of the mode_string string suitable for chmod
int cp(string from, string to)
Copies the file from to the new position to . If there is no system function for cp, a new file will be created and the old one copied manually in chunks of 65536 bytes. This function can also copy directories recursively.
0 on error, 1 on success
This function keeps file and directory permissions unlike in Pike 7.6 and earlier
int file_equal(string file_1, string file_2)
Returns nonzero if the given paths are files with identical content, returns zero otherwise. Zero is also returned for any sort of I/O error.
void async_cp(string from, string to, function(int:void) callback, mixed ... args)
Copy a file asynchronously.
This function is similar to cp() , but works asynchronously.
Name of file to copy.
Name of file to create or replace with a copy of from .
Function to be called on completion.
The first argument will be 1 on success, and 0 (zero)
otherwise. The rest of the arguments to callback are passed
verbatim from args .
Extra arguments to pass to callback .
For callback to be called, the backend must be active (ie
main() must have returned -1, or Pike.DefaultBackend
get called in some other way). The actual copying may start
before the backend has activated.
Currently the file sizes are not compared, so the destination file (to ) may be truncated.
cp() , sendfile()
int mkdirhier(string pathname, void|int mode)
Creates zero or more directories to ensure that the given pathname is a directory.
If a mode is given, it's used for the new directories after being &'ed with the current umask (on OS'es that support this).
Returns zero on failure and nonzero on success.
mkdir()
int recursive_rm(string path)
Remove a file or a directory tree.
Returns 0 on failure, nonzero otherwise.
rm
int recursive_mv(string from, string to)
Copy a file or a directory tree by copying and then removing. It's not the fastest but works on every OS and works well across different file systems.
Returns 0 on failure, nonzero otherwise.
recursive_rm cp
object sendfile(array(string) headers, File from, int offset, int len, array(string) trailers, File to)
object sendfile(array(string) headers, File from, int offset, int len, array(string) trailers, File to, function(int:void) callback, mixed ... args)
Sends headers followed by len bytes starting at offset from the file from followed by trailers to the file to . When completed callback will be called with the total number of bytes sent as the first argument, followed by args .
Any of headers , from and trailers may be left out
by setting them to 0.
Setting offset to -1 means send from the current position in
from .
Setting len to -1 means send until from 's end of file is
reached.
The sending is performed asynchronously, and may complete both before and after the function returns.
For callback to be called, the backend must be active (ie
main() must have returned -1, or Pike.DefaultBackend
get called in some other way).
In some cases, the backend must also be active for any sending to be performed at all.
In Pike 7.4.496, Pike 7.6.120 and Pike 7.7 and later the backend associated with to will be used rather than the default backend. Note that you usually will want from to have the same backend as to .
FIXME: Support for timeouts?
Stdio.File->set_nonblocking()
void werror(string s)
Write a message to stderr. Stderr is normally the console, even if the process output has been redirected to a file or pipe.
This function is identical to predef::werror() .
predef::werror()
array(int) get_all_active_fd()
Returns the id of all the active file descriptors.
constant Stdio.PROP_BIDIRECTIONAL
Document this constant.
constant Stdio.PROP_BUFFERED
Document this constant.
constant Stdio.PROP_SHUTDOWN
Document this constant.
constant Stdio.PROP_NONBLOCK
Document this constant.
constant Stdio.PROP_REVERSE
Document this constant.
constant Stdio.PROP_IPC
Document this constant.
constant Stdio.IPPROTO
Document this constant.
constant Stdio.__OOB__
Implementation level of nonblocking I/O OOB support.
|
This constant only exists when OOB operations are available, i.e. when __HAVE_OOB__ is 1.
constant Stdio.__HAVE_OOB__
Exists and has the value 1 if OOB operations are available.
In Pike 7.5 and later OOB operations are always present.
string _sprintf(int type, void|mapping flags)
mapping(string:mapping) gethostip()
Returns the IP addresses of the host.
Returns a mapping that maps interface name to a mapping with more information about that interface. That information mapping looks as follows.
|
constant Stdio.XATTR_CREATE
Used by setxattr function and method to signify a pure create, which will fail if the attribute already exists.
constant Stdio.XATTR_REPLACE
Used by setxattr function and method to signify a replace, which will fail the the attribute does not already exists.
constant Stdio.DN_ACCESS
Used in File.notify() to get a callback when files within a directory are accessed.
constant Stdio.DN_MODIFY
Used in File.notify() to get a callback when files within a directory are modified.
constant Stdio.DN_CREATE
Used in File.notify() to get a callback when new files are created within a directory.
constant Stdio.DN_DELETE
Used in File.notify() to get a callback when files are deleted within a directory.
constant Stdio.DN_RENAME
Used in File.notify() to get a callback when files within a directory are renamed.
constant Stdio.DN_ATTRIB
Used in File.notify() to get a callback when attributes of files within a directory are changed.
constant Stdio.DN_MULTISHOT
Used in File.notify() . If DN_MULTISHOT is used, signals will be sent for all notifications the program has registred for. Otherwise only the first event the program is listening for will be received and then the program must reregister for the events to receive futher events.
| CLASS Stdio.Stream |
The Stdio.Stream API.
This class exists purely for typing reasons.
Use in types in place of Stdio.File where only blocking stream-oriented I/O is done with the object.
NonblockingStream , BlockFile , File , FILE
| CLASS Stdio.NonblockingStream |
The Stdio.NonblockingStream API.
This class exists purely for typing reasons.
Use in types in place of Stdio.File where nonblocking and/or blocking stream-oriented I/O is done with the object.
Stream , BlockFile , File , FILE
inherit Stream : Stream
| CLASS Stdio.BlockFile |
The Stdio.BlockFile API.
This class exists purely for typing reasons.
Use in types in place of Stdio.File where only blocking I/O is done with the object.
Stream , NonblockingStream , File , FILE
inherit Stream : Stream
| CLASS Stdio.File |
This is the basic I/O object, it provides socket and pipe communication as well as file access. It does not buffer reads and writes or provide line-by-line reading, that is done with Stdio.FILE object.
The file or stream will normally be closed when this object is destructed (unless there are more objects that refer to the same file through use of assign or dup ). Objects do not contain cyclic references in themselves, so they will be destructed timely when they run out of references.
Stdio.FILE
inherit Fd_ref : Fd_ref
int errno()
Returns the error code for the last command on this file. Error code is normally cleared when a command is successful.
int open(string filename, string mode)
int open(string filename, string mode, int mask)
Open a file for read, write or append. The parameter mode should contain one or more of the following letters:
|
mode should always contain at least one of the letters
"r" or "w".
The parameter mask is protection bits to use if the file is
created. Default is 0666 (read+write for all in octal
notation).
This function returns 1 for success, 0 otherwise.
close() , create()
int openpt(string mode)
Open the master end of a pseudo-terminal pair. The parameter mode should contain one or more of the following letters:
|
mode should always contain at least one of the letters
"r" or "w".
grantpt()
int open_socket(int|string|void port, string|void address, int|string|void family_hint)
This makes this file into a socket ready for connections. The reason for this function is so that you can set the socket to nonblocking or blocking (default is blocking) before you call connect() .
If you give a port number to this function, the socket will be bound to this port locally before connecting anywhere. This is only useful for some silly protocols like FTP. The port can also be specified as a string, giving the name of the service associated with the port.
You may specify an address to bind to if your machine has many IP numbers.
A protocol family for the socket can be specified. If no family is specified, one which is appropriate for the address is automatically selected. Thus, there is normally no need to specify it. If you do not want to specify a bind address, you can provide the address as a hint here instead, to allow the automatic selection to work anyway.
This function returns 1 for success, 0 otherwise.
connect() , set_nonblocking() , set_blocking()
int connect(string host, int|string port, void|string client, void|int|string client_port)
This function connects a socket previously created with open_socket() to a remote socket through TCP/IP. The host argument is the hostname or IP number of the remote machine. A local IP and port can be explicitly bound by specifying client and client_port .
This function returns 1 for success, 0 otherwise.
In nonblocking mode 0 (zero) may be returned and
errno() set to EWOULDBLOCK or
WSAEWOULDBLOCK. This should not be regarded as a
connection failure. In nonblocking mode you need to wait for a
write or close callback before you know if the connection failed
or not.
query_address() , async_connect() , connect_unix()
int connect_unix(string path)
Open a UNIX domain socket connection to the specified destination.
Returns 1 on success, and 0 on failure.
Nonblocking mode is not supported while connecting
function(:string) read_function(int nbytes)
Returns a function that when called will call read with nbytes as argument. Can be used to get various callback functions, eg for the fourth argument to String.SplitIterator .
String.SplitIterator|LineIterator line_iterator(int|void trim)
Returns an iterator that will loop over the lines in this file. If trim is true, all '\r' characters will be removed from the input.
int async_connect(string host, int|string port, function(int:void) callback, mixed ... args)
Open a TCP/IP connection asynchronously.
This function is similar to connect() , but works asynchronously.
Hostname or IP to connect to.
Port number or service name to connect to.
Function to be called on completion.
The first argument will be 1 if a connection was
successfully estabished, and 0 (zero) on failure.
The rest of the arguments to callback are passed
verbatim from args .
Extra arguments to pass to callback .
Returns 0 on failure, and 1 if callback
will be used.
The socket may be opened with open_socket() ahead of the call to this function, but it is not required.
This object is put in callback mode by this function. For callback to be called, the backend must be active. See e.g. set_read_callback for more details about backends and callback mode.
The socket will be in nonblocking state if the connection is successful, and any callbacks will be cleared.
connect() , open_socket() , set_nonblocking()
File pipe(void|int required_properties)
This function creates a pipe between the object it was called in and an object that is returned.
Binary or (predef::`|() ) of required PROP_ properties.
|
The default is PROP_NONBLOCK|PROP_BIDIRECTIONAL.
If PROP_BIDIRECTIONAL isn't specified, the read-end is this object, and the write-end is the returned object (unless PROP_REVERSE has been specified, in which case it is the other way around).
The two ends of a bi-directional pipe are indistinguishable.
If the File object this function is called in was open to begin with, it will be closed before the pipe is created.
Calling this function with an argument of 0 is not the same as calling it with no arguments.
Process.create_process() , PROP_IPC , PROP_NONBLOCK , PROP_SHUTDOWN , PROP_BUFFERED , PROP_REVERSE , PROP_BIDIRECTIONAL
File openat(string filename, string mode)
File openat(string filename, string mode, int mask)
Open a file relative to an open directory.
File.statat() , File.unlinkat()
void Stdio.File()
void Stdio.File(string filename)
void Stdio.File(string filename, string mode)
void Stdio.File(string filename, string mode, int mask)
void Stdio.File(string descriptorname)
void Stdio.File(int fd)
void Stdio.File(int fd, string mode)
There are four basic ways to create a Stdio.File object. The first is calling it without any arguments, in which case the you'd have to call open() , connect() or some other method which connects the File object with a stream.
The second way is calling it with a filename and open mode . This is the same thing as cloning and then calling open() , except shorter and faster.
The third way is to call it with descriptorname of "stdin",
"stdout" or "stderr". This will open the specified
standard stream.
For the advanced users, you can use the file descriptors of the
systems (note: emulated by pike on some systems - like NT). This is
only useful for streaming purposes on unix systems. This is not
recommended at all if you don't know what you're into. Default
mode for this is "rw".
Open mode will be filtered through the system UMASK. You might need to use chmod() later.
open() , connect() , Stdio.FILE ,
int assign(File|Fd o)
This function takes a clone of Stdio.File and assigns all variables of this file from it. It can be used together with dup() to move files around.
dup()
File dup()
This function returns a clone of Stdio.File with all variables copied from this file.
All variables, even id, are copied.
assign()
int close()
int close(string direction)
Close the file. Optionally, specify "r", "w" or "rw" to close just the read, just the write or both read and write directions of the file respectively.
An exception is thrown if an I/O error occurs.
Nonzero is returned if the file wasn't open in the specified direction, zero otherwise.
This function will not call the close_callback.
open , open_socket
void set_read_callback(function(mixed:int) read_cb)
void set_write_callback(function(mixed:int) write_cb)
void set_read_oob_callback(function(mixed:int) read_oob_cb)
void set_write_oob_callback(function(mixed:int) write_oob_cb)
void set_close_callback(function(mixed:int) close_cb)
These functions set the various callbacks, which will be called when various events occur on the stream. A zero as argument will remove the callback.
A Pike.Backend object is responsible for calling the callbacks. It requires a thread to be waiting in it to execute the calls. That means that only one of the callbacks will be running at a time, so you don't need mutexes between them.
Unless you've specified otherwise with the set_backend
function, the default backend Pike.DefaultBackend will be
used. It's normally activated by returning -1 from the
main function and will then execute in the main thread.
When data arrives on the stream, read_cb will be called with some or all of that data as the second argument.
When the stream has buffer space over for writing, write_cb will be called so that you can write more data to it.
This callback is also called after the remote end of a socket connection has closed the write direction. An attempt to write data to it in that case will generate a System.EPIPE errno. If the remote end has closed both directions simultaneously (the usual case), Pike will first attempt to call close_cb , then this callback (unless close_cb has closed the stream).
When out-of-band data arrives on the stream, read_oob_cb will be called with some or all of that data as the second argument.
When the stream allows out-of-band data to be sent, write_oob_cb will be called so that you can write more out-of-band data to it.
If the OS doesn't separate the write events for normal and out-of-band data, Pike will try to call write_oob_cb first. If it doesn't write anything, then write_cb will be tried. This also means that write_oob_cb might get called when the remote end of a connection has closed the write direction.
When an error or an end-of-stream in the read direction occurs, close_cb will be called. errno will return the error, or zero in the case of an end-of-stream.
The name of this callback is rather unfortunate since it really has nothing to do with a close: The stream is still open when close_cb is called (you might not be able to read and/or write to it, but you can still use things like query_address , and the underlying file descriptor is still allocated). Also, this callback will not be called for a local close, neither by a call to close or by destructing this object.
Also, close_cb will not be called if a remote close only occurs in the write direction; that is handled by write_cb (or possibly write_oob_cb ).
Events to read_cb and close_cb will be automatically deregistered if an end-of-stream occurs, and all events in the case of an error. I.e. there won't be any more calls to the callbacks unless they are reinstalled. This doesn't affect the callback settings - query_read_callback et al will still return the installed callbacks.
If the stream is a socket performing a nonblocking connect (see open_socket and connect ), a connection failure will call close_cb , and a successful connect will call either read_cb or write_cb as above.
All callbacks will receive the id set by set_id as first argument.
If a callback returns -1, no other callback or call out
will be called by the backend in that round. I.e. the caller of
the backend will get control back right away. For the default
backend that means it will immediately start another round and
check files and call outs anew.
These functions do not set the file nonblocking.
Callbacks are also set by set_nonblocking() .
After a callback has been called, it's disabled until it has accessed the stream accordingly, i.e. the write_cb callback is disabled after it's been called until something has been written with write , and the write_oob_cb callback is likewise disabled until something has been written with write_oob . Since the data already has been read when the read callbacks are called, this effect is not noticeable for them.
Installing callbacks means that you will start doing I/O on the stream from the thread running the backend. If you are running these set functions from another thread you must be prepared that the callbacks can be called immediately by the backend thread, so it might not be safe to continue using the stream in this thread.
Because of that, it's useful to talk about "callback mode" when any callback is installed. In callback mode the stream should be seen as "bound" to the backend thread. For instance, it's only the backend thread that reliably can end callback mode before the stream is "handed over" to another thread.
Callback mode has nothing to do with nonblocking mode - although the two often are used together they don't have to be.
The file object will stay referenced from the backend object as long as there are callbacks that can receive events.
Setting a close callback without a read callback currently only works when there's no risk of getting more data on the stream. Otherwise the close callback will be silently deregistered if data arrives.
set_nonblocking() , set_id() , set_backend , query_read_callback , query_write_callback , query_read_oob_callback , query_write_oob_callback , query_close_callback
function(mixed:int) query_read_callback()
function(mixed:int) query_write_callback()
function(mixed:int) query_read_oob_callback()
function(mixed:int) query_write_oob_callback()
function(mixed:int) query_close_callback()
These functions return the currently installed callbacks for the respective events.
set_nonblocking() , set_read_callback , set_write_callback , set_read_oob_callback , set_write_oob_callback , set_close_callback
void set_id(mixed id)
This function sets the id of this file. The id is mainly
used as an identifier that is sent as the first argument to all
callbacks. The default id is 0 (zero). Another possible
use of the id is to hold all data related to this file in a
mapping or array.
query_id()
mixed query_id()
This function returns the id that has been set with set_id() .
set_id()
void set_nonblocking(function(mixed:int) read_callback, function(mixed:int) write_callback, function(mixed:int) close_callback)
void set_nonblocking(function(mixed:int) read_callback, function(mixed:int) write_callback, function(mixed:int) close_callback, function(mixed:int) read_oob_callback, function(mixed:int) write_oob_callback)
void set_nonblocking()
This function sets a stream to nonblocking mode and installs the
specified callbacks. See the set_*_callback functions
for details about them. If no arguments are given, the callbacks
will be cleared.
As opposed to calling the set callback functions separately, this function will set all the callbacks and nonblocking mode atomically so that no callback gets called in between. That avoids races in case the backend is executed by another thread.
Out-of-band data was not be supported on Pike 0.5 and earlier, and not on Pike 0.6 through 7.4 if they were compiled with the option '--without-oob'.
set_blocking() , set_read_callback() , set_write_callback() , set_read_oob_callback() , set_write_oob_callback() , set_close_callback() set_nonblocking_keep_callbacks() , set_blocking_keep_callbacks()
void set_blocking()
This function clears all callbacks and sets a stream to blocking mode. i.e. reading, writing and closing will wait until data has been transferred before returning.
The callbacks are cleared and blocking mode is set in one atomic operation, so no callback gets called in between if the backend is running in another thread.
Even so, if the stream is in callback mode (i.e. if any callbacks are installed) then only the backend thread can use this function reliably; it might otherwise already be running in a callback which is about to call e.g. write when the stream becomes blocking.
set_nonblocking() , set_nonblocking_keep_callbacks() , set_blocking_keep_callbacks()
void set_nonblocking_keep_callbacks()
void set_blocking_keep_callbacks()
Toggle between blocking and nonblocking, without changing the callbacks.
set_nonblocking() , set_blocking()
mapping tcgetattr()
int tcsetattr(mapping attr)
int tcsetattr(mapping attr, string when)
Gets/sets term attributes. The returned value/the attr parameter is a mapping on the form
|
Negative values are not allowed as indata, but might appear in the result from tcgetattr when the actual value is unknown. tcsetattr returns 0 if failed.
The argument when to tcsetattr describes when the changes are to take effect:
|
// setting the terminal in raw mode: Stdio.stdin->tcsetattr((["ECHO":0,"ICANON":0,"VMIN":0,"VTIME":0]));
Unknown flags are ignored by tcsetattr() . tcsetattr always changes the attribute, so only include attributes that actually should be altered in the attribute mapping.
Terminal rows and columns setting by tcsetattr() is not currently supported.
string read()
string read(int len)
string read(int len, int(0..1) not_all)
Read data from a file or a stream.
Attempts to read len bytes from the file, and return it as a string. Less than len bytes can be returned if:
end-of-file is encountered for a normal file, or
it's a stream that has been closed from the other end, or
it's a stream in nonblocking mode, or
it's a stream and not_all is set, or
not_all isn't set and an error occurred (see below).
If not_all is nonzero, read() does not try its best to read as many bytes as you have asked for, but merely returns as much as the system read function returns. This is mainly useful with stream devices which can return exactly one row or packet at a time. If not_all is used in blocking mode, read() only blocks if there's no data at all available.
If something goes wrong and not_all is set, zero is returned. If something goes wrong and not_all is zero or left out, then either zero or a string shorter than len is returned. If the problem persists then a later call to read() fails and returns zero, however.
If everything went fine, a call to errno() directly afterwards returns zero. That includes an end due to end-of-file or remote close.
If no arguments are given, read() reads to the end of the file or stream.
It's not necessary to set not_all to avoid blocking reading when nonblocking mode is used.
When at the end of a file or stream, repeated calls to read() returns the empty string since it's not considered an error. The empty string is never returned in other cases, unless nonblocking mode is used or len is zero.
read_oob() , write()
int(-1..1) peek()
int(-1..1) peek(int|float timeout)
int(-1..1) peek(int|float timeout, int not_eof)
Check if there is data available to read, or wait some time for available data to read.
More specifically, a later call to read() will return immediately, either due to data being present, or due to some error (eg if a socket has been closed).
Timeout in seconds.
Flag for specifying handling of end of file. The following values are currently defined:
|
|
errno() , read()
The function may be interrupted prematurely of the timeout (due to signals); check the timing manually if this is imporant.
The not_eof parameter was added in Pike 7.7.
This function was not available on NT in Pike 7.6 and earlier.
string read_oob()
string read_oob(int len)
string read_oob(int len, int(0..1) not_all)
Attempts to read len bytes of out-of-band data from the stream, and returns it as a string. Less than len bytes can be returned if:
the stream has been closed from the other end, or
nonblocking mode is used, or
not_all is set, or
not_all isn't set and an error occurred (see below).
If not_all is nonzero, read_oob() only returns as many bytes of out-of-band data as are currently available.
If something goes wrong and not_all is set, zero is returned. If something goes wrong and not_all is zero or left out, then either zero or a string shorter than len is returned. If the problem persists then a later call to read_oob() fails and returns zero, however.
If everything went fine, a call to errno() directly afterwards returns zero. That includes an end due to remote close.
If no arguments are given, read_oob() reads to the end of the stream.
Out-of-band data was not supported in Pike 0.5 and earlier, and not in Pike 0.6 through 7.4 if they were compiled with the option '--without-oob'.
It is not guaranteed that all out-of-band data sent from the other end is received. Most streams only allow for a single byte of out-of-band data at a time.
It's not necessary to set not_all to avoid blocking reading when nonblocking mode is used.
When at the end of a file or stream, repeated calls to read() returns the empty string since it's not considered an error. The empty string is never returned in other cases, unless nonblocking mode is used or len is zero.
read() , write_oob()
int write(string data)
int write(string format, mixed ... extras)
int write(array(string) data)
int write(array(string) format, mixed ... extras)
Write data to a file or a stream.
Writes data and returns the number of bytes that were actually written. It can be less than the size of the given data if
some data was written successfully and then something went wrong, or
nonblocking mode is used and not all data could be written without blocking.
-1 is returned if something went wrong and no bytes were written. If only some data was written due to an error and that error persists, then a later call to write() fails and returns -1.
If everything went fine, a call to errno() directly afterwards returns zero.
If data is an array of strings, they are written in sequence.
If more than one argument is given, sprintf() is used to format them using format . If format is an array, the strings in it are concatenated and the result is used as format string.
Writing of wide strings is not supported. You have to encode the data somehow, e.g. with string_to_utf8 or with one of the charsets supported by Locale.Charset.encoder .
read() , write_oob()
int write_oob(string data)
int write_oob(string format, mixed ... extras)
Write out-of-band data to a stream.
Writes out-of-band data to a stream and returns how many bytes that were actually written. It can be less than the size of the given data if some data was written successfully and then something went wrong.
-1 is returned if something went wrong and no bytes were written. If only some data was written due to an error and that error persists, then a later call to write_oob() fails and returns -1.
If everything went fine, a call to errno() directly afterwards returns zero.
If more than one argument is given, sprintf() is used to format them.
Out-of-band data was not supported in Pike 0.5 and earlier, and not in Pike 0.6 through 7.4 if they were compiled with the option '--without-oob'.
It is not guaranteed that all out-of-band data sent from the other end is received. Most streams only allow for a single byte of out-of-band data at a time. Some streams sends the rest of the data as ordinary data.
read_oob() , write()
string grantpt()
If this file has been created by calling openpt() , return the filename of the associated pts-file. This function should only be called once.
This function is only available on some platforms.
int close()
int close(string direction)
Close a file or stream.
If direction is not specified, both the read and the write direction is closed. Otherwise only the directions specified is closed.
Nonzero is returned if the file or stream wasn't open in the specified direction, zero otherwise.
An exception is thrown if an I/O error occurs.
close() has no effect if this file object has been associated with an already opened file, i.e. if open() was given an integer as the first argument.
open() , open_socket()
int open(string filename, string mode)
int open(string filename, string mode, int access)
int open(int fd, string mode)
Open a file, or use an existing fd.
If filename is given, attempt to open the named file. If fd is given instead, it should be the file descriptor for an already opened file, which will then be used by this object.
mode describes how the file is opened. It's a case-insensitive string consisting of one or more of the following letters:
Open for reading.
Open for writing.
Append new data to the end.
Create the file if it doesn't exist already.
Truncate the file to zero length if it already contains data.
Use only together with "w".
Open exclusively - the open fails if the file already exists.
Use only together with "c". Note that it's not safe to
assume that this is atomic on some systems.
access specifies the permissions to use if a new file is created. It is a UNIX style permission bitfield:
User has read permission.
User has write permission.
User has execute permission.
Group has read permission.
Group has write permission.
Group has execute permission.
Others have read permission.
Others have write permission.
Others have execute permission.
It's system dependent on which of these bits that are actually
heeded. If access is not specified, it defaults to
00666, but note that on UNIX systems it's masked with the
process umask before use.
Returns nonzero on success and 0 (zero) on failure. If
there is a failure then errno returns the error code.
close()
Stdio.File openat(string filename, string mode)
Stdio.File openat(string filename, string mode, int access)
Open a file relative to an opened directory.
Returns a new file object on success, and 0 (zero) on failure.
Not available on all architectures, or in Pike 7.6 and earlier.
open() , statat() , unlinkat()
int openpt(string mode)
Open the master end of a pseudo-terminal pair.
This function returns 1 for success, 0 otherwise.
grantpt()
int(0..1) sync()
Flush buffers to disk.
Returns 0 (zero) and sets errno on failure.
Returns 1 on success.
int seek(int pos)
int seek(int unit, int mult)
int seek(int unit, int mult, int add)
Seek to a specified offset in a file.
If mult or add are specified, pos is calculated as
pos = unit *mult + add .
If pos is negative then it is relative to the end of the file, otherwise it's an absolute offset from the start of the file.
Returns the new offset, or -1 on failure.
The arguments mult and add are considered obsolete, and should not be used.
tell()
int tell()
Returns the current offset in the file.
seek()
int(0..1) truncate(int length)
Truncate a file.
Truncates the file to the specified length length .
Returns 1 on success, and 0 (zero) on failure.
open()
Stat stat()
Get status for an open file.
This function returns the same information as the function
file_stat() , but for the file it is called in. If file is not
an open file, 0 (zero) is returned. Zero is also returned
if file is a pipe or socket.
See file_stat() for a description of the return value.
Prior to Pike 7.1 this function returned an array(int).
file_stat() , statat()
Stat statat(string path, void|int(0..1) symlink)
Get status for a file relative an open directory.
This function returns the same information as the function
file_stat() , but relative to the file it is called in. If file is not
an open file, 0 (zero) is returned. Zero is also returned
if file is a pipe or socket.
See file_stat() for a description of the return value.
Not available on all architectures, or in Pike 7.6 and earlier.
file_stat() , stat() , openat() , unlinkat()
int unlinkat(string f)
Remove a file or directory relative to an open file.
Returns 0 (zero) on failure, 1 otherwise.
rm() , openat() , statat()
array(string) listxattr()
Return an array of all extended attributes set on the file
string getxattr(string attr)
Return the value of a specified attribute, or 0 if it does not exist
void removexattr(string attr)
Remove the specified extended attribute.
void setxattr(string attr, string value, int flags)
Set the attribute attr to the value value .
The flags parameter can be used to refine the semantics of the operation.
Stdio.XATTR_CREATE specifies a pure create, which fails if the named attribute exists already.
Stdio.XATTR_REPLACE specifies a pure replace operation, which fails if the named attribute does not already exist.
By default (no flags), the extended attribute will be created if need be, or will simply replace the value if the attribute exists.
1 if successful, 0 otherwise, setting errno.
int errno()
Return the errno for the latest failed file operation.
int mode()
Returns the open mode for the file.
|
open()
void set_backend(Pike.Backend backend)
Set the backend used for the callbacks.
The backend keeps a reference to this object only when it is in callback mode. So if this object hasn't got any active callbacks and it runs out of other references, it will still be destructed quickly (after closing, if necessary).
Also, this object does not keep a reference to the backend.
query_backend , set_nonblocking , set_read_callback , set_write_callback
Pike.Backend query_backend()
Return the backend used for the callbacks.
set_backend
void set_nonblocking()
Sets this file to nonblocking operation.
Nonblocking operation is not supported on all Stdio.File objects. Notably it is not guaranteed to be supported on objects returned by pipe() unless PROP_NONBLOCK was specified in the call to pipe() .
set_blocking()
void set_blocking()
Sets this file to blocking operation.
This is the inverse operation of set_nonblocking() .
set_nonblocking()
void set_close_on_exec(int(0..1) yes_no)
Marks the file as to be closed in spawned processes.
This function determines whether this file will be closed when calling exec().
Default is that the file WILL be closed on exec except for stdin, stdout and stderr.
Process.create_process() , exec()
int is_open()
Returns true if the file is open.
If the file is a socket that has been closed from the remote side, this function might still return true.
Most methods can't be called for a file descriptor that isn't open. Notable exceptions errno , mode , and the set and query functions for callbacks and backend.
int query_fd()
Returns the file descriptor number associated with this object.
int release_fd()
Returns the file descriptor number associated with this object, in addition to releasing it so that this object behaves as if closed. Other settings like callbacks and backend remain intact. take_fd can later be used to reinstate the file descriptor so that the state is restored.
query_fd() , take_fd()
void take_fd(int fd)
Rehooks the given file descriptor number to be associated with this object. As opposed to using open with a file descriptor number, it will be closed by this object upon destruct or when close is called.
release_fd()
void set_buffer(int bufsize, string mode)
void set_buffer(int bufsize)
Set internal socket buffer.
This function sets the internal buffer size of a socket or stream.
The second argument allows you to set the read or write buffer by
specifying "r" or "w".
It is not guaranteed that this function actually does anything, but it certainly helps to increase data transfer speed when it does.
open_socket() , accept()
Stdio.File pipe()
Stdio.File pipe(int flags)
int dup2(Stdio.File to)
Duplicate a file over another.
This function works similarly to assign() , but instead of making the argument a reference to the same file, it creates a new file with the same properties and places it in the argument.
Returns 1 on success and 0 (zero) on failure.
In Pike 7.7 and later to need not be open, in which case a new fd is allocated.
Note also that to is also assigned to the same backend (if any) as this object.
assign() , dup()
Stdio.Fd dup()
Duplicate the file.
dup2()
int(0..1) open_socket(int|void port, string|void addr, int|string|void family_hint)
int(0..1) set_keepalive(int(0..1) on_off)
int(0..1) connect_unix(string filename)
Open a UNIX domain socket connection to the specified destination.
In nonblocking mode, success is indicated with the write-callback, and failure with the close-callback or the read_oob-callback.
Returns 1 on success, and 0 on failure.
In nonblocking mode 0 (zero) may be returned and errno() set
to EWOULDBLOCK or WSAEWOULDBLOCK. This should not be regarded
as a connection failure.
int(0..1) connect(string dest_addr, int dest_port)
int(0..1) connect(string dest_addr, int dest_port, string src_addr, int src_port)
Open a TCP/IP connection to the specified destination.
In nonblocking mode, success is indicated with the write-callback, and failure with the close-callback or the read_oob-callback.
Returns 1 on success, and 0 on failure.
In nonblocking mode 0 (zero) may be returned and errno() set
to EWOULDBLOCK or WSAEWOULDBLOCK. This should not be regarded
as a connection failure.
string query_address()
string query_address(int(0..1) local)
Get address and port of a socket end-point.
If the argument local is not specified, or is 0
(zero), the remote end-point is returned. Otherwise, if local
is 1, the local end-point is returned.
This function returns the address and port of a socket end-point
on the form "x.x.x.x port" (IPv4) or
"x:x:x:x:x:x:x:x port" (IPv6).
If this file is not a socket, is not connected, or some other
error occurs, 0 (zero) is returned and errno() will
return the error code.
An error is thrown if the socket (or file) isn't open.
connect()
Stdio.File `<<(string data)
Stdio.File `<<(mixed data)
Write some data to a file.
If data is not a string, it is casted to string, and then written to the file.
Throws an error if not all data could be written.
write()
void Stdio.File(string filename)
void Stdio.File(string filename, string mode)
void Stdio.File(string filename, string mode, in access)
void Stdio.File(int fd)
void Stdio.File(int fd, string mode)
See open() .
open()
void proxy(Stdio.File from)
Starts a thread that asynchronously copies data from from to this file.
Stdio.sendfile()
Stdio.FileLockKey lock()
Stdio.FileLockKey lock(int(0..1) is_recursive)
Makes an exclusive file lock on this file.
trylock()
Stdio.FileLockKey trylock()
Stdio.FileLockKey trylock(int(0..1) is_recursive)
Attempts to place a file lock on this file.
lock()
void notify(void|int notification, function(void:void) callback)
Receive notification when change occur within the fd. To use, create a Stdio.File object of a directory like Stdio.File(".") and then call notify() with the appropriate parameters.
When a program registers for some notification, only the first notification will be received unless DN_MULTISHOT is specified as part of the notification argument.
At present, this function is Linux-specific and requires a kernel which supports the F_NOTIFY fcntl() call.
What to notify the callback of. See the Stdio.DN_* constants for more information about possible notifications.
Function which should be called when notification is received. The function gets the signal used to indicate the notification as its argument and shouldn't return anyting.
| CLASS Stdio.Port |
Handles listening to socket ports. Whenever you need a bound socket that is open and listens for connections you should use this program.
inherit _port : _port
void Stdio.Port()
void Stdio.Port(int|string port)
void Stdio.Port(int|string port, function accept_callback)
void Stdio.Port(int|string port, function accept_callback, string ip)
void Stdio.Port("stdin")
void Stdio.Port("stdin", function accept_callback)
If the first argument is other than "stdin" the arguments will
be passed to bind() .
When create is called with "stdin" as the first argument, a
socket is created out of the file descriptor 0. This is only
useful if it actually is a socket to begin with.
bind
File accept()
This function completes a connection made from a remote machine to this port. It returns a two-way stream in the form of a clone of Stdio.File . The new file is by initially set to blocking mode.
Stdio.File
mixed set_id(mixed id)
This function sets the id used for accept_callback by this port. The default id is this_object() .
query_id
mixed query_id()
This function returns the id for this port. The id is normally the first argument to accept_callback.
set_id
int errno()
If the last call done on this port failed, this function will return an integer describing what went wrong. Refer to your unix manual for further information.
int listen_fd(int fd, void|function accept_callback)
This function does the same as bind , except that instead of creating a new socket and bind it to a port, it expects the file descriptor fd to be an already open port.
This function is only for the advanced user, and is generally used when sockets are passed to Pike at exec time.
bind , accept
int bind(int|string port, void|function accept_callback, void|string ip)
Opens a socket and binds it to port number on the local machine. If the second argument is present, the socket is set to nonblocking and the callback funcition is called whenever something connects to it. The callback will receive the id for this port as argument and should typically call accept to establish a connection.
If the optional argument ip is given, bind will try to bind to an interface with that host name or IP number.
1 is returned on success, zero on failure. errno provides further details about the error in the latter case.
accept , set_id
int bind_unix(string path, void|function accept_callback)
Opens a Unix domain socket at the given path in the file system. If the second argument is present, the socket is set to nonblocking and the callback funcition is called whenever something connects to it. The callback will receive the id for this port as argument and should typically call accept to establish a connection.
1 is returned on success, zero on failure. errno provides further details about the error in the latter case.
This function is only available on systems that support Unix domain sockets.
accept , set_id
void close()
Closes the socket.
void Stdio.Port(int|string port, void|function accept_callback, void|string ip)
void Stdio.Port("stdin", void|function accept_callback)
When called with an int or any string except "stdin" as
first argument, this function does the same as bind() would do
with the same arguments.
When called with "stdin" as argument, a socket is created
out of the file descriptor 0. This is only useful if that actually
IS a socket to begin with.
bind , listen_fd
Stdio.File accept()
Get the first connection request waiting for this port and return it as a connected socket.
If no connection request is waiting and the port is in nonblocking mode (i.e. an accept callback is installed) then zero is returned. Otherwise this function waits until a connection has arrived.
In Pike 7.7 and later the resulting file object will be assigned to the same backend as the port object.
string query_address()
Get the address and port of the local socket end-point.
This function returns the address and port of a socket end-point
on the form "x.x.x.x port" (IPv4) or
"x:x:x:x:x:x:x:x port" (IPv6).
If there is some error querying or formatting the address,
0 (zero) is returned and errno() will return the
error code.
An error is thrown if the socket isn't bound.
void set_backend(Pike.Backend backend)
Set the backend used for the accept callback.
The backend keeps a reference to this object as long as the port is accepting connections, but this object does not keep a reference to the backend.
query_backend
Pike.Backend query_backend()
Return the backend used for the accept callback.
set_backend
| CLASS Stdio.FILE |
Stdio.FILE is a buffered version of Stdio.File , it inherits Stdio.File and has most of the functionality of Stdio.File . However, it has an input buffer that allows line-by-line input.
It also has support for automatic charset conversion for both input and output (see Stdio.FILE()->set_charset() ).
The output part of Stdio.FILE is currently not buffered.
inherit File : file
void set_charset(string charset)
Sets the input and output charset of this file to the specified charset .
The default charset is "ISO-8859-1".
Consider using one of ISO-IR-196 ("\e%G" - switch to UTF-8 with return) or ISO-IR-190 ("\e%/G" - switch to UTF-8 level 1 no return) or ISO-IR-191 ("\e%/H" - switch to UTF-8 level 2 no return) or ISO-IR-192 ("\e%/I" - switch to UTF-8 level 3 no return) or ISO-IR-193 ("\e%/J" - switch to UTF-16 level 1 no return) or ISO-IR-194 ("\e%/K" - switch to UTF-16 level 2 no return) or ISO-IR-195 ("\e%/L" - switch to UTF-16 level 3 no return) or ISO-IR-162 ("\e%/@" - switch to UCS-2 level 1) or ISO-IR-163 ("\e%/A" - switch to UCS-4 level 1) or ISO-IR-174 ("\e%/C" - switch to UCS-2 level 2) or ISO-IR-175 ("\e%/D" - switch to UCS-4 level 2) or ISO-IR-176 ("\e%/E" - switch to UCS-2 level 3) or ISO-IR-177 ("\e%/F" - switch to UCS-4 level 3) or ISO-IR-178 ("\e%B" - switch to UTF-1) automatically to encode wide strings.
string gets(int(0..1)|void not_all)
Read one line of input with support for input conversion.
Set this parameter to ignore partial lines at EOF. This is useful for eg monitoring a growing logfile.
This function returns the line read if successful, and 0 if
no more lines are available.
ngets() , read() , line_iterator() , set_charset()
array(string) ngets(void|int(1..) n, int(0..1)|void not_all)
Get n lines.
Number of lines to get, or all remaining if zero.
Set this parameter to ignore partial lines at EOF. This is useful for eg monitoring a growing logfile.
File pipe(void|int flags)
Same as Stdio.File()->pipe() .
Returns an Stdio.File object, NOT a Stdio.FILE object.
FILE openat(string filename, string mode)
FILE openat(string filename, string mode, int mask)
Same as Stdio.File()->openat() , but returns a Stdio.FILE object.
Stdio.File()->openat()
int write(array(string)|string what, mixed ... fmt)
Write what with support for output_conversion.
Stdio.File()->write()
int printf(string format, mixed ... data)
This function does approximately the same as:
write (sprintf (format ,@data )).
write() , sprintf()
object _get_iterator()
Returns an iterator that will loop over the lines in this file.
line_iterator()
object line_iterator(int|void trim)
Returns an iterator that will loop over the lines in this file. If trim is true, all '\r' characters will be removed from the input.
It's not supported to call this method more than once unless a call to seek is done in advance. Also note that it's not possible to intermingle calls to read , gets or other functions that read data with the line iterator, it will produce unexpected results since the internal buffer in the iterator will not contain sequential file-data in those cases.
_get_iterator()
string read(int|void bytes, void|int(0..1) now)
Read bytes (wide-) characters with buffering and support for input conversion.
Stdio.File()->read() , set_charset() , unread()
void unread(string s)
This function puts a string back in the input buffer. The string can then be read with eg read() , gets() or getchar() .
read() , gets() , getchar() , ungets()
void ungets(string s)
This function puts a line back in the input buffer. The line can then be read with eg read() , gets() or getchar() .
The string is autoterminated by an extra line-feed.
read() , gets() , getchar() , unread()
int getchar()
This function returns one character from the input stream.
Returns the ISO-10646 (Unicode) value of the character.
Returns an int and not a string of length 1.
| CLASS Stdio.UDP |
UDP (User Datagram Protocol) handling.
inherit files.UDP : UDP
UDP set_nonblocking()
UDP set_nonblocking(function(mapping(string:int|string):void) read_cb, mixed ... extra_args)
Set this object to nonblocking mode.
If read_cb and extra_args are specified, they will be passed on to set_read_callback() .
The called object.
UDP set_read_callback(function(mapping(string:int|string):) read_cb, mixed ... extra_args)
The read_cb function will receive a mapping similar to the mapping returned by read() :
|
The called object.
read()
int(0..1) close()
Closes an open UDP port.
This method was introduced in Pike 7.5.
UDP bind(int|string port)
UDP bind(int|string port, string address)
Binds a port for receiving or transmitting UDP.
Throws error when unable to bind port.
int(0..1) enable_broadcast()
Set the broadcast flag. If enabled then sockets receive packets sent to a broadcast address and they are allowed to send packets to a broadcast address.
Returns 1 on success, 0 (zero) otherwise.
This is normally only avalable to root users.
int(0..1) enable_multicast(string reply_address)
Set the local device for a multicast socket. See also the Unix man page for setsocketopt IPPROTO_IP IP_MULTICAST_IF.
int set_multicast_ttl(int ttl)
Set the time-to-live value of outgoing multicast packets for this socket. It is very important for multicast packets to set the smallest TTL possible. The default is 1 which means that multicast packets don't leacl the local network unless the user program explicitly request it. See also the Unix man page for setsocketopt IPPROTO_IP IP_MULTICAST_TTL.
int add_membership(string group, void|string address)
Join a multicast group. group contains the address of the multicast group the application wants to join or leave. It must be a valid multicast address. address is the address of the local interface with wich the system should join to the multicast group. If not provided the system will select an appropriate interface. See also the Unix man page for setsocketopt IPPROTO_IP ADD_MEMBERSHIP.
drop_membership
int drop_membership(string group, void|string address)
Leave a multicast group.
add_membership
int(0..1) wait(int|float timeout)
Check for data and wait max. timeout seconds.
Returns 1 if data are ready, 0 (zero) otherwise.
mapping(string:int|string) read()
mapping(string:int|string) read(int flag)
Read from the UDP socket.
Flag flag is a bitfield, 1 for out of band data and 2 for peek
mapping(string:int|string) in the form ([ "data" : string received data "ip" : string received from this ip "port" : int ...and this port ])
set_read_callback()
int send(string to, int|string port, string message)
int send(string to, int|string port, string message, int flags)
Send data to a UDP socket. The recipient address will be to and port will be port .
Flag flag is a bitfield, 1 for out of band data and 2 for don't route flag.
The number of bytes that were actually written.
object set_blocking()
Sets this object to be blocking.
int(0..1) connect(string address, int|string port)
Establish an UDP connection.
This function connects an UDP socket previously created with Stdio.UDP() to a remote socket. The address is the IP name or number for the remote machine.
Returns 1 on success, 0 (zero) otherwise.
If the socket is in nonblocking mode, you have to wait for a write or close callback before you know if the connection failed or not.
bind() , query_address()
string query_address()
Returns the local address of a socket on the form "x.x.x.x port". If this file is not a socket, not connected or some other error occurs, zero is returned.
void set_backend(Pike.Backend backend)
Set the backend used for the read callback.
The backend keeps a reference to this object as long as there can be calls to the read callback, but this object does not keep a reference to the backend.
query_backend
Pike.Backend query_backend()
Return the backend used for the read callback.
set_backend
int errno()
Returns the error code for the last command on this object. Error code is normally cleared when a command is successful.
UDP set_type(int sock_type)
UDP set_type(int sock_type, int family)
Sets socket type and protocol family.
array(int) get_type()
Returns socket type and protocol family.
constant Stdio.UDP.MSG_OOB
Document this constant.
constant Stdio.UDP.MSG_PEEK
Document this constant.
| CLASS Stdio.FakeFile |
A string wrapper that pretends to be a Stdio.File object.
constant Stdio.FakeFile.is_fake_file
This constant can be used to distinguish a FakeFile object from a real Stdio.File object.
int close(void|string direction)
Stdio.File()->close()
void Stdio.FakeFile(string data, void|string type, void|int pointer)
Stdio.File()->create()
this_program dup()
Stdio.File()->dup()
int errno()
Always returns 0.
Stdio.File()->errno()
Stdio.Stat stat()
Returns size and the creation time of the string.
String.SplitIterator line_iterator(int|void trim)
Stdio.File()->line_iterator()
mixed query_id()
Stdio.File()->query_id()
void set_id(mixed _id)
Stdio.File()->set_id()
function(:string) read_function(int nbytes)
Stdio.File()->read_function()
int(-1..1) peek(int|float|void timeout)
Stdio.File()->peek()
string query_address(void|int(0..1) is_local)
Always returns 0.
Stdio.File()->query_address()
string read(void|int(0..) len, void|int(0..1) not_all)
Stdio.File()->read()
int seek(int pos, void|int mult, void|int add)
Stdio.File()->seek()
int(1..1) sync()
Always returns 1.
Stdio.File()->sync()
int tell()
Stdio.File()->tell()
int(0..1) truncate(int length)
Stdio.File()->truncate()
int(-1..) write(string|array(string) str, mixed ... extra)
Stdio.File()->write()
void set_blocking()
Stdio.File()->set_blocking
void set_blocking_keep_callbacks()
Stdio.File()->set_blocking_keep_callbacks
void set_nonblocking(function rcb, function wcb, function ccb, function rocb, function wocb)
Stdio.File()->set_blocking
void set_nonblocking_keep_callbacks()
Stdio.File()->set_blocking_keep_callbacks
void set_close_callback(function cb)
Stdio.File()->set_close_callback
void set_read_callback(function cb)
Stdio.File()->set_read_callback
void set_read_oob_callback(function cb)
Stdio.File()->set_read_oob_callback
void set_write_callback(function cb)
Stdio.File()->set_write_callback
void set_write_oob_callback(function cb)
Stdio.File()->set_write_oob_callback
function query_close_callback()
Stdio.File()->query_close_callback
function query_read_callback()
Stdio.File()->query_read_callback
function query_read_oob_callback()
Stdio.File()->query_read_oob_callback
function query_write_callback()
Stdio.File()->query_write_callback
function query_write_oob_callback()
Stdio.File()->query_write_oob_callback
mixed cast(string to)
A FakeFile can be casted to a string.
int(0..) _sizeof()
Sizeof on a FakeFile returns the size of its contents.
| CLASS Stdio.Readline |
OutputController get_output_controller()
get current output control object
Terminal output controller object
InputController get_input_controller()
get current input control object
Terminal input controller object
string get_prompt()
Return the current prompt string.
string set_prompt(string newp, array(string)|void newattrs)
Set the prompt string.
New prompt string
Terminal attributes
void set_echo(int onoff)
Set text echo on or off.
1 for echo, 0 for no echo.
string gettext()
Document this function
int getcursorpos()
Document this function
int setcursorpos(int p)
Document this function
int setmark(int p)
Document this function
int getmark()
Document this function
void insert(string s, int p)
Document this function
void delete(int p1, int p2)
Document this function
array(int) pointmark()
Document this function
string region(int ... args)
Document this function
void kill(int p1, int p2)
Document this function
void add_to_kill_ring(string s)
Document this function
string kill_ring_yank()
Document this function
void history(int n)
Document this function
void delta_history(int d)
Changes the line to a line from the history d steps from the current entry (0 being the current line, negative values older, and positive values newer).
Only effective if you have a history object.
void redisplay(int clear, int|void nobackup)
Document this function
string newline()
Document this function
void eof()
Document this function
void message(string msg)
Print a message to the output device
void write(string msg, void|int word_wrap)
Document this function
void list_completions(array(string) c)
Document this function
void set_nonblocking(function f)
Document this function
void set_blocking()
Document this function
string edit(string data, string|void local_prompt, array(string)|void attrs)
Document this function
string read(string|void prompt, array(string)|void attrs)
Document this function
void enable_history(array(string)|History|int hist)
Document this function
History get_history()
Document this function
void Stdio.Readline(object|void infd, object|string|void interm, object|void outfd, object|string|void outterm)
Creates a Readline object, that takes input from infd and has output on outfd .
Defaults to Stdio.stdin .
Defaults to Stdio.Terminfo.getTerm() .
Defaults to infd , unless infd is 0, in which case outfd defaults to Stdio.stdout .
Defaults to interm .
| CLASS Stdio.Readline.OutputController |
Ought to have support for charset conversion.
void turn_on(string ... atts)
Set the provided attributes to on.
void turn_off(string ... atts)
Set the provided attributes to off.
void disable()
void enable()
int check_columns()
Check and return the terminal width.
In Pike 7.4 and earlier this function returned void.
get_number_of_columns
int get_number_of_columns()
Returns the width of the terminal.
Does not check the width of the terminal.
check_columns
void low_write(string s, void|int word_break)
void write(string s, void|int word_break, void|int hide)
void low_move_downward(int n)
void low_move_upward(int n)
void low_move_forward(int n)
void low_move_backward(int n)
void low_erase(int n)
void move_forward(string s)
void move_backward(string s)
void erase(string s)
void newline()
void bol()
void clear(int|void partial)
void beep()
void Stdio.Readline.OutputController(.File|void _outfd, .Terminfo.Termcap|string|void _term)
| CLASS Stdio.Readline.InputController |
Ought to have support for charset conversion.
int isenabled()
int enable(int ... e)
int disable()
int run_blocking()
void set_close_callback(function(:int) ccb)
void nullbindings()
Clears the bindings.
void grabnextkey(function g)
function bindstr(string str, function f)
function unbindstr(string str)
function getbindingstr(string str)
function bindtc(string cap, function f)
function unbindtc(string cap)
function getbindingtc(string cap)
string parsekey(string k)
function bind(string k, function f)
function unbind(string k)
function getbinding(string k, string cap)
mapping(string:function) getbindings()
void Stdio.Readline.InputController(object|void _infd, object|string|void _term)
| CLASS Stdio.Readline.DefaultEditKeys |
void self_insert_command(string str)
void quoted_insert()
void newline()
void up_history()
void down_history()
void backward_delete_char()
void delete_char()
void delete_char_or_eof()
void forward_char()
void backward_char()
void beginning_of_line()
void end_of_line()
void transpose_chars()
void capitalize_word()
void upcase_word()
void downcase_word()
void forward_word()
void backward_word()
void kill_word()
void backward_kill_word()
void kill_line()
void kill_whole_line()
void yank()
void kill_ring_save()
void kill_region()
void set_mark()
void swap_mark_and_point()
void redisplay()
void clear_screen()
void set_default_bindings()
void Stdio.Readline.DefaultEditKeys(object readline)
| CLASS Stdio.Readline.History |
string encode()
int get_history_num()
string history(int n, string text)
void initline()
void finishline(string text)
void set_max_history(int maxhist)
void Stdio.Readline.History(int maxhist, void|array(string) hist)
| CLASS Stdio.Fd_ref |
Proxy class that contains stub functions that call the corresponding functions in Fd .
Used by File .
Fd Stdio.Fd_ref._fd
Object to which called functions are relayed.
| CLASS Stdio.Fd |
Low level I/O operations. Use File instead.
| CLASS Stdio.Stat |
This object is used to represent file status information from e.g. file_stat() .
It contains the following items usually found in a C struct stat:
File mode (see mknod(2)).
File size in bytes.
User ID of the file's owner.
Group ID of the file's owner.
Time of last access in seconds since 00:00:00 UTC, 1970-01-01.
Time of last data modification.
Time of last file status change.
Inode number.
Number of links.
ID of the device containing a directory entry for this file.
ID of the device.
It also contains some items that correspond to the C IS* macros:
Set if the file is a regular file.
Set if the file is a directory.
Set if the file is a symbolic link. Note that symbolic links are normally followed by the stat functions, so this might only be set if you turn that off, e.g. by giving a nonzero second argument to file_stat() .
Set if the file is a FIFO (aka named pipe).
Set if the file is a socket.
Set if the file is a character device.
Set if the file is a block device.
There are also some items that provide alternative representations of the above:
The type as a string, can be any of "reg",
"dir", "lnk", "fifo", "sock",
"chr", "blk", and "unknown".
The file mode encoded as a string in ls -l style, e.g.
"drwxr-xr-x".
Note that some items might not exist or have meaningful values on some platforms.
Additionally, the object may be initialized from or casted to an
array on the form of a 'traditional' LPC stat-array, and
it's also possible to index the object directly with integers as
if it were such an array. The stat-array has this format:
| ||||||||||||||||
It's possible to modify the stat struct by assigning values to
the items. They essentially work as variables, although some of
them affect others, e.g. setting isdir clears isreg
and setting mode_string changes many of the other items.
void Stdio.Stat(void|object|array stat)
A new Stdio.Stat object can be initialized in two ways:
stat is an object, typically another Stdio.Stat . The
stat info is copied from the object by getting the values of
mode, size, atime, mtime,
ctime, uid, gid, dev, ino,
nlink, and rdev.
stat is a seven element array on the 'traditional' LPC stat-array form (see the class doc).
| Module Stdio.Terminfo |
Termcap getTermcap(string term)
Returns the terminal description object for term from the systems termcap database. Returns 0 if not found.
Stdio.Terminfo.getTerm, Stdio.Terminfo.getTerminfo
Terminfo getTerminfo(string term)
Returns the terminal description object for term from the systems terminfo database. Returns 0 if not found.
Stdio.Terminfo.getTerm, Stdio.Terminfo.getTermcap
Termcap getTerm(string|void term)
Returns an object describing the terminal term. If term is not specified, it will default to getenv("TERM") or if that fails to "dumb".
Lookup of terminal information will first be done in the systems terminfo database, and if that fails in the termcap database. If neither database exists, a hardcoded entry for "dumb" will be used.
Stdio.Terminfo.getTerminfo, Stdio.Terminfo.getTermcap, Stdio.getFallbackTerm
Termcap getFallbackTerm(string term)
Returns an object describing the fallback terminal for the terminal term . This is usually equvivalent to Stdio.Terminfo.getTerm("dumb") .
Stdio.Terminfo.getTerm
int is_tty()
Returns 1 if Stdio.stdin is connected to an interactive terminal that can handle backspacing, carriage return without linefeed, and the like.
| CLASS Stdio.Terminfo.Termcap |
Termcap terminal description object.
inherit TermMachine : TermMachine
array(string) Stdio.Terminfo.Termcap.aliases
string tputs(string s)
Put termcap string
void Stdio.Terminfo.Termcap(string cap, TermcapDB|void tcdb, int|void maxrecurse)
| CLASS Stdio.Terminfo.Terminfo |
Terminfo terminal description object
inherit TermMachine : TermMachine
array(string) Stdio.Terminfo.Terminfo.aliases
string tputs(string s)
Document this function
void Stdio.Terminfo.Terminfo(string filename)
| Module Parser |
HTML get_xml_parser()
Returns a Parser.HTML initialized for parsing XML. It has all the flags set properly for XML syntax and callbacks to ignore comments, CDATA blocks and unknown PI tags, but it has no registered tags and doesn't decode any entities.
string decode_numeric_xml_entity(string chref)
Decodes the numeric XML entity chref , e.g. "4" and returns the character as a string. chref is the name part of the entity, i.e. without the leading '&' and trailing ';'. Returns zero if chref isn't on a recognized form or if the character number is too large to be represented in a string.
HTML html_entity_parser()
string parse_html_entities(string in)
HTML html_entity_parser(int noerror)
string parse_html_entities(string in, int noerror)
Parse any HTML entities in the string to unicode characters. Either return a complete parser (to build on or use) or parse a string. Throw an error if there is an unrecognized entity in the string if noerror is not set.
Currently using XHTML 1.0 tables.
string encode_html_entities(string raw)
Encode characters to HTML entities, e.g. turning "<" into
"<".
The characters that will be encoded are characters <= 32,
"\"&'<>" and characters >= 127 and <= 160 and characters
>= 255.
| CLASS Parser.SGML |
| CLASS Parser.SGML.SGML |
This is a handy simple parser of SGML-like syntax like HTML. It doesn't do anything advanced, but finding the corresponding end-tags.
It's used like this:
array res=Parser.SGML()->feed(string)->finish()->result();
The resulting structure is an array of atoms, where the atom can be a string or a tag. A tag contains a similar array, as data.
A string
"<gat> <gurka> </gurka> <banan> <kiwi> </gat>"results in({ tag "gat" object with data: ({ tag "gurka" object with data: ({ " " }) tag "banan" object with data: ({ " " tag "kiwi" object with data: ({ " " }) }) }) })
ie, simple "tags" (not containers) are not detected, but containers are ended implicitely by a surrounding container _with_ an end tag.
The 'tag' is an object with the following variables:
string name; - name of tag mapping args; - argument to tag int line,char,column; - position of tag string file; - filename (see <ref>create</ref>) array(SGMLatom) data; - contained data
string Parser.SGML.SGML.file
void Parser.SGML.SGML()
void Parser.SGML.SGML(string filename)
This object is created with this filename. It's passed to all created tags, for debug and trace purposes.
No, it doesn't read the file itself. See feed() .
object feed(string s)
array(SGMLatom|string) finish()
array(SGMLatom|string) result(string s)
Feed new data to the object, or finish the stream. No result can be used until finish() is called.
Both finish() and result() return the computed data.
feed() returns the called object.
| CLASS Parser.SGML.SGML.SGMLatom |
string Parser.SGML.SGML.SGMLatom.name
mapping Parser.SGML.SGML.SGMLatom.args
int Parser.SGML.SGML.SGMLatom.line
int Parser.SGML.SGML.SGMLatom.char
int Parser.SGML.SGML.SGMLatom.column
string Parser.SGML.SGML.SGMLatom.file
array(SGMLatom) Parser.SGML.SGML.SGMLatom.data
| CLASS Parser.RCS |
A RCS file parser that eats a RCS *,v file and presents nice pike data structures of its contents.
inherit Parser._RCS : _RCS
string Parser.RCS.head
Version number of the head version of the file
string|int(0..0) Parser.RCS.branch
The default branch (or revision), if present, 0 otherwise
array(string) Parser.RCS.access
The usernames listed in the ACCESS section of the RCS file
string|int(0..0) Parser.RCS.comment
The RCS file comment if present, 0 otherwise
string Parser.RCS.expand
The keyword expansion options (as named by RCS) if present,
0 otherwise
string Parser.RCS.description
The RCS file description
mapping(string:string) Parser.RCS.locks
Maps from username to revision for users that have acquired locks on this file
int(0..1) Parser.RCS.strict_locks
1 if strict locking is set, 0 otherwise
mapping(string:string) Parser.RCS.tags
Maps tag names (indices) to tagged revision numbers (values)
mapping(string:string) Parser.RCS.branches
Maps branch numbers (indices) to branch names (values)
mapping(string:Revision) Parser.RCS.revisions
Data for all revisions of the file. The indices of the mapping are the revision numbers, whereas the values are the data from the corresponding revision.
array(mapping) Parser.RCS.trunk
Data for all revisions on the trunk, sorted in the same order as the RCS file stored them - ie descending, most recent first, I'd assume (rcsfile(5), of course, fails to state such irrelevant information).
void Parser.RCS(string|void file_name, string|int(0..0)|void file_contents)
Initializes the RCS object.
The path to the raw RCS file (includes trailing ",v"). Used mainly for error reporting (truncated RCS file).
If a string is provided, that string will be parsed to
initialize the RCS object. If a zero (0) is sent, no
initialization will be performed at all. If no value is given at
all, but file_name was provided, that file will be loaded and
parsed for object initialization.
array parse_admin_section(string|array raw)
Lower-level API function for parsing only the admin section (the initial chunk of an RCS file, see manpage rcsfile(5)) of an RCS file. After running parse_admin_section , the RCS object will be initialized with the values for head , branch , access , branches , tokenize , tags , locks , strict_locks , comment and expand .
The tokenized RCS file, or the raw RCS-file data.
The rest of the RCS file, admin section removed.
parse_delta_sections , parse_deltatext_sections , parse , create
Does not handle rcsfile(5) newphrase skipping.
array parse_delta_sections(array raw)
Lower-level API function for parsing only the delta sections (the second chunk of an RCS file, see manpage rcsfile(5)) of an RCS file. After running parse_delta_sections , the RCS object will be initialized with the value of description and populated revisions mapping and trunk array. Their Revision members are however only populated with the members Revision->revision , Revision->branch , Revision->time , Revision->author , Revision->state , Revision->branches , Revision->rcs_next , Revision->ancestor and Revision->next .
The tokenized RCS file, with admin section removed. (See parse_admin_section .)
The rest of the RCS file, delta sections removed.
parse_admin_section , tokenize , parse_deltatext_sections , parse , create
Does not handle rcsfile(5) newphrase skipping.
array(array(string)) tokenize(string data)
Tokenize an RCS file into tokens suitable as argument to the various parse functions
The RCS file data
An array with arrays of tokens
void parse_deltatext_sections(array raw, void|function(string:void) progress_callback, array|void callback_args)
Lower-level API function for parsing only the deltatext sections (the final and typically largest chunk of an RCS file, see manpage rcsfile(5)) of an RCS file. After a parse_deltatext_sections run, the RCS object will be fully populated.
The tokenized RCS file, with admin and delta sections removed. (See parse_admin_section , tokenize and parse_delta_sections .)
This optional callback is invoked with the revision of the deltatext about to be parsed (useful for progress indicators).
Optional extra trailing arguments to be sent to progress_callback
parse_admin_section , parse_delta_sections , parse , create
Does not handle rcsfile(5) newphrase skipping.
this_program parse(array raw, void|function(string:void) progress_callback)
Parse the RCS file raw and initialize all members of this object fully initialized.
The unprocessed RCS file.
Passed on to parse_deltatext_sections .
The fully initialized object (only returned for API convenience; the object itself is destructively modified to match the data extracted from raw )
parse_admin_section , parse_delta_sections , parse_deltatext_sections , create
string get_contents_for_revision(string|Revision rev)
Returns the file contents from the revision rev , without performing any keyword expansion.
expand_keywords_for_revision
string expand_keywords_for_revision(string|Revision rev, string|void text, int|void override_binary)
Expand keywords and return the resulting text according to the expansion rules set for the file.
The revision to apply the expansion for.
If supplied, substitute keywords for that text instead using values that would apply for the given revision. Otherwise, revision rev is used.
If 1, perform expansion even if the file was checked in as binary.
The Log keyword (which lacks sane quoting rules) is not expanded. Keyword expansion rules set in CVSROOT/cvswrappers are ignored. Only implements the -kkv and -kb expansion modes.
get_contents_for_revision
| CLASS Parser.RCS.DeltatextIterator |
Iterator for the deltatext sections of the RCS file. Typical usage:
string raw = Stdio.read_file(my_rcs_filename); Parser.RCS rcs = Parser.RCS(my_rcs_filename, 0); raw = rcs->parse_delta_sections(rcs->parse_admin_section(raw)); foreach(rcs->DeltatextIterator(raw); int n; Parser.RCS.Revision rev) do_something(rev);
void Parser.RCS.DeltatextIterator(array deltatext_section, void|function(string:void) progress_callback, void|array(mixed) progress_callback_args)
the deltatext section of the RCS file in its entirety
This optional callback is invoked with the revision of the deltatext about to be parsed (useful for progress indicators).
Optional extra trailing arguments to be sent to progress_callback
the rcsfile(5) manpage outlines the sections of an RCS file
int Parser.RCS.DeltatextIterator.nint(0..1) read_next()
Drops the leading whitespace before next revision's deltatext entry and sets this_rev to the revision number we're about to read.
int index()
the number of deltatext entries processed so far (0..N-1, N being the total number of revisions in the rcs file)
Revision value()
the Revision at whose deltatext data we are, updated with its info
int(0..1) `!()
1 if the iterator has processed all deltatext entries, 0 otherwise.
this_program `+=(int nsteps)
Advance nsteps sections.
Returns the iterator object.
int(0..1) next()
like `+= (1), but returns 0 if the iterator is finished
int(0..1) first()
Restart not implemented; always returns 0 (==failed)
int parse_deltatext_section(array raw, int o)
Chops off the first deltatext section from the token array raw and
returns the rest of the string, or the value 0 (zero) if
we had already visited the final deltatext entry. The deltatext's
data is stored destructively in the appropriate entry of the
revisions array.
raw +o must start with a deltatext entry for this method to work
does not handle rcsfile(5) newphrase skipping
if the rcs file is truncated, this method writes a descriptive error to stderr and then returns 0 - some nicer error handling wouldn't hurt
| CLASS Parser.RCS.Revision |
All data tied to a particular revision of the file.
string Parser.RCS.Revision.revision
the revision number (i e RCS ->revisions["1.1"]->revision == "1.1")
string Parser.RCS.Revision.author
the name of the user that committed the revision
array(string) Parser.RCS.Revision.branches
when there are branches from this revision, an array of the revision numbers where each branch starts, otherwise 0
string Parser.RCS.Revision.state
the state of the revision - typically "Exp" or "dead"
Calendar.TimeRange Parser.RCS.Revision.time
the (UTC) date and time when the revision was committed (second precision)
string Parser.RCS.Revision.branch
the branch name on which this revision was committed (calculated according to how cvs manages branches)
string Parser.RCS.Revision.rcs_next
the revision stored next in the rcs file, or 0 if none exists
string Parser.RCS.Revision.ancestor
the revision of the ancestor of this revision, or 0 if this was the initial revision
string Parser.RCS.Revision.next
the revision that succeeds this revision, or 0 if none exists
string Parser.RCS.Revision.log
the log message associated with the revision
int Parser.RCS.Revision.lines
the number of lines this revision contained, altogether (not of particular interest for binary files)
int Parser.RCS.Revision.added
the number of lines that were added from the previous revision to make this revision (for the initial revision too)
int Parser.RCS.Revision.removed
the number of lines that were removed from the previous revision to make this revision
| CLASS Parser.HTML |
This is a simple parser for SGML structured markups. It's not really HTML, but it's useful for that *! purpose.
The simple way to use it is to give it some information about available tags and containers, and what callbacks those is to call.
The object is easily reused, by calling the clone() function.
add_tag , add_container , finish
Parser.HTML _set_tag_callback(function|string|array to_call)
Parser.HTML _set_entity_callback(function|string|array to_call)
Parser.HTML _set_data_callback(function|string|array to_call)
These functions set up the parser object to call the given callbacks upon tags, entities and/or data. The callbacks will only be called if there isn't another tag/container/entity handler for these.
The callback function will be called with the parser object as first argument, and the active string as second. Note that no parsing of the contents has been done. Both endtags and normal tags are called; there is no container parsing.
The return values from the callbacks are handled in the same way as the return values from callbacks registered with add_tag and similar functions.
The data callback will be called as seldom as possible with the longest possible string, as long as it doesn't get called out of order with any other callback. It will never be called with a zero length string.
If a string or array is given instead of a function, it will act as the return value from the function. Arrays or empty strings is probably preferable to avoid recursion.
Returns the object being called.
Parser.HTML add_tag(string name, mixed to_do)
Parser.HTML add_container(string name, mixed to_do)
Parser.HTML add_entity(string entity, mixed to_do)
Parser.HTML add_quote_tag(string name, mixed to_do, string end)
Parser.HTML add_tags(mapping(string:mixed) tags)
Parser.HTML add_containers(mapping(string:mixed) containers)
Parser.HTML add_entities(mapping(string:mixed) entities)
Registers the actions to take when parsing various things. Tags, containers, entities are as usual. add_quote_tag() adds a special kind of tag that reads any data until the next occurrence of the end string immediately before a tag end.
This argument can be any of the following.
|
The callback function can return:
|
Returns the object being called.
tags , containers , entities
Parser.HTML clear_tags()
Parser.HTML clear_containers()
Parser.HTML clear_entities()
Parser.HTML clear_quote_tags()
Removes all registered definitions in the different categories.
Returns the object being called.
add_tag , add_tags , add_container , add_containers , add_entity , add_entities
mapping(string:mixed) tags()
mapping(string:mixed) containers()
mapping(string:mixed) entities()
Returns the current callback settings. When matching is done case insensitively, all names will be returned in lowercase.
Implementation note: These run in constant time since they return copy-on-write mappings.
add_tag , add_tags , add_container , add_containers , add_entity , add_entities
mapping(string:array(mixed|string)) quote_tags()
Returns the current callback settings. The values are arrays ({callback, end_quote}). When matching is done case insensitively, all names will be returned in lowercase.
Implementation note: quote_tags() allocates a new mapping for every call and thus, unlike e.g. tags() runs in linear time.
add_quote_tag
Parser.HTML feed()
Parser.HTML feed(string s, void|int do_parse)
Feed new data to the Parser.HTML object. This will start a scan and may result in callbacks. Note that it's possible that all data fed isn't processed - to do that, call finish() .
If the function is called without arguments, no data is fed, but
the parser is run. If the string argument is followed by a
0, ->feed(s,0);, the string is fed, but the parser
isn't run.
Returns the object being called.
finish , read , feed_insert
Parser.HTML feed_insert(string s)
This pushes a string on the parser stack.
Returns the object being called.
Don't use!
Parser.HTML finish()
Parser.HTML finish(string s)
Finish a parser pass. A string may be sent here, similar to feed().
Returns the object being called.
string|array(mixed) read()
string|array(mixed) read(int max_elems)
Read parsed data from the parser object.
Returns a string of parsed data if the parser isn't in mixed_mode , an array of arbitrary data otherwise.
Parser.HTML write_out(mixed ... args)
Send data to the output stream, i.e. it won't be parsed and it won't be sent to the data callback, if any.
Any data is allowed when the parser is running in mixed_mode . Only strings are allowed otherwise.
Returns the object being called.
array(int) at()
int at_line()
int at_char()
int at_column()
Returns the current position. Characters and columns count from
0, lines count from 1.
at() gives an array with the following layout.
| ||||||||
string current()
Gives the current range of data, ie the whole tag/entity/etc being parsed in the current callback. Returns zero if there's no current range, i.e. when the function is not called in a callback.
string tag_name()
Gives the name of the current tag, or zero. If used from an entity callback, it gives the string inside the entity.
mapping(string:mixed) tag_args(void|mixed default_value)
Gives the arguments of the current tag, parsed to a convenient mapping consisting of key:value pairs. If the current thing isn't a tag, it gives zero. default_value is used for arguments which have no value in the tag. If default_value isn't given, the value is set to the same string as the key.
string tag_content()
Gives the content of the current tag, if it's a container or quote tag. Otherwise returns zero.
array tag(void|mixed default_value)
Returns the equivalent of the following calls.
| ||||||||
string context()
Returns the current output context as a string.
|
The return value can also be a single character string, in which case the context is a quoted argument. The string contains the starting quote character.
This function is typically only useful in entity callbacks, which can be called both from text and argument values of different sorts.
splice_arg
string parse_tag_name(string tag)
Parses the tag name from a tag string without the surrounding
brackets, i.e. a string on the form "tagname some='tag'
args".
Returns the tag name or an empty string if none.
mapping parse_tag_args(string tag)
Parses the tag arguments from a tag string without the name and
surrounding brackets, i.e. a string on the form "some='tag'
args".
Returns a mapping containing the tag arguments.
tag_args
mapping _inspect()
This is a low-level way of debugging a parser. This gives a mapping of the internal state of the Parser.HTML object.
The format and contents of this mapping may change without further notice.
Parser.HTML clone(mixed ... args)
Clones the Parser.HTML object. A new object of the same class is created, filled with the parse setup from the old object.
This is the simpliest way of flushing a parse feed/output.
The arguments to clone is sent to the new object, simplifying work for custom classes that inherits Parser.HTML .
Returns the new object.
create is called _before_ the setup is copied.
Parser.HTML set_extra(mixed ... args)
Sets the extra arguments passed to all tag, container and entity callbacks.
Returns the object being called.
array get_extra()
Gets the extra arguments set by set_extra() .
Returns the object being called.
string splice_arg(void|string name)
If given a string, it sets the splice argument name to it. It returns the old splice argument name.
If a splice argument name is set, it's parsed in all tags, both those with callbacks and those without. Wherever it occurs, its value (after being parsed for entities in the normal way) is inserted directly into the tag. E.g:
<foo arg1="val 1" splice="arg2='val 2' arg3" arg4>
becomes
<foo arg1="val 1" arg2='val 2' arg3 arg4>
if "splice" is set as the splice argument name.
int case_insensitive_tag(void|int value)
All tags and containers are matched case insensitively, and argument names are converted to lowercase. Tags added with add_quote_tag() are not affected, though. Switching to case insensitive mode and back won't preserve the case of registered tags and containers.
int ignore_tags(void|int value)
Do not look for tags at all. Normally tags are matched even when
there's no callbacks for them at all. When this is set, the tag
delimiters '<' and '>' will be treated as any
normal character.
int ignore_unknown(void|int value)
Treat unknown tags and entities as text data, continuing parsing for tags and entities inside them.
When functions are specified with _set_tag_callback() or _set_entity_callback() , all tags or entities, respectively, are considered known. However, if one of those functions return 1 and ignore_unknown is set, they are treated as text data instead of making another call to the same function again.
int lazy_argument_end(void|int value)
A '>' in a tag argument closes both the argument and the
tag, even if the argument is quoted.
int lazy_entity_end(void|int value)
Normally, the parser search indefinitely for the entity end
character (i.e. ';'). When this flag is set, the
characters '&', '<', '>', '"',
''', and any whitespace breaks the search for the entity
end, and the entity text is then ignored, i.e. treated as
data.
int match_tag(void|int value)
Unquoted nested tag starters and enders will be balanced when parsing tags. This is the default.
int max_parse_depth(void|int value)
Maximum recursion depth during parsing. Recursion occurs when a
tag/container/entity/quote tag callback function returns a string
to be reparsed. The default value is 10.
int mixed_mode(void|int value)
Allow callbacks to return arbitrary data in the arrays, which will be concatenated in the output.
int reparse_strings(void|int value)
When a plain string is used as a tag/container/entity/quote tag callback, it's not reparsed if this flag is unset. Setting it causes all such strings to be reparsed.
int ws_before_tag_name(void|int value)
Allow whitespace between the tag start character and the tag name.
int xml_tag_syntax(void|int value)
Whether or not to use XML syntax to tell empty tags and container tags apart.
|
int nestling_entity_end(void|int value)
int ignore_comments(void|int value)
| Module Parser.LR |
LALR(1) parser generator.
| ENUM Parser.LR.SeverityLevel |
Severity level
| CLASS Parser.LR.Priority |
Specifies the priority and associativity of a rule.
int Parser.LR.Priority.value
Priority value
int Parser.LR.Priority.assoc
Associativity
|
void Parser.LR.Priority(int p, int a)
Create a new priority object.
Priority.
Associativity.
| CLASS Parser.LR.Rule |
This object is used to represent a BNF-rule in the LR parser.
int Parser.LR.Rule.nonterminal
Non-terminal this rule reduces to.
array(string|int) Parser.LR.Rule.symbols
The actual rule
function|string Parser.LR.Rule.action
Action to do when reducing this rule. function - call this function. string - call this function by name in the object given to the parser. The function is called with arguments corresponding to the values of the elements of the rule. The return value of the function will be the value of this non-terminal. The default rule is to return the first argument.
int Parser.LR.Rule.has_tokens
This rule contains tokens
int Parser.LR.Rule.num_nonnullables
This rule has this many non-nullable symbols at the moment.
int Parser.LR.Rule.number
Sequence number of this rule (used for conflict resolving) Also used to identify the rule.
Priority Parser.LR.Rule.pri
Priority and associativity of this rule.
void Parser.LR.Rule(int nt, array(string|int) r, function|string|void a)
Create a BNF rule.
The rule
rule : nonterminal ":" symbols ";" { add_rule };
might be created as
rule(4, ({ 9, ":", 5, ";" }), "add_rule");
where 4 corresponds to the nonterminal "rule", 9 to "nonterminal" and 5 to "symbols", and the function "add_rule" is too be called when this rule is reduced.
Non-terminal to reduce to.
Symbol sequence that reduces to nt.
Action to do when reducing according to this rule. function - Call this function. string - Call this function by name in the object given to the parser. The function is called with arguments corresponding to the values of the elements of the rule. The return value of the function will become the value of this non-terminal. The default rule is to return the first argument.
| CLASS Parser.LR.ErrorHandler |
Class handling reporting of errors and warnings.
optional int(-1..1) Parser.LR.ErrorHandler.verbose
Verbosity level
|
void Parser.LR.ErrorHandler(int(-1..1)|void verbosity)
Create a new error handler.
Level of verbosity.
verbose
| CLASS Parser.LR.Parser |
This object implements an LALR(1) parser and compiler.
Normal use of this object would be:
set_error_handler
{add_rule, set_priority, set_associativity}*
set_symbol_to_string
compile
{parse}*
mapping(int:array(Rule)) Parser.LR.Parser.grammar
The grammar itself.
Kernel Parser.LR.Parser.start_state
The initial LR0 state.
int Parser.LR.Parser.lr_error
Error code
mapping(string:Kernel) Parser.LR.Parser.known_states
LR0 states that are already known to the compiler.
function(SeverityLevel:void) Parser.LR.Parser.error_handler
Compile error and warning handler.
string rule_to_string(Rule r)
Pretty-prints a rule to a string.
Rule to print.
string item_to_string(Item i)
Pretty-prints an item to a string.
Item to pretty-print.
string state_to_string(Kernel state)
Pretty-prints a state to a string.
State to pretty-print.
string _sprintf()
Pretty-prints the current grammar to a string.
mixed cast(string type)
Implements casting.
Type to cast to.
void set_priority(string terminal, int pri_val)
Sets the priority of a terminal.
Terminal to set the priority for.
Priority; higher = prefer this terminal.
void set_associativity(string terminal, int assoc)
Sets the associativity of a terminal.
Terminal to set the associativity for.
Associativity; negative - left, positive - right, zero - no associativity.
void set_symbol_to_string(void|function(int|string:string) s_to_s)
Sets the symbol to string conversion function. The conversion function is used by the various *_to_string functions to make comprehensible output.
Symbol to string conversion function. If zero or not specified, use the built-in function.
void set_error_handler(void|function(SeverityLevel:void) handler)
Sets the error report function.
Function to call to report errors and warnings. If zero or not specifier, use the built-in function.
void add_rule(Rule r)
Add a rule to the grammar.
Rule to add.
StateQueue Parser.LR.Parser.s_q
Contains all states used. In the queue section are the states that remain to be compiled.
int compile()
Compiles the grammar into a parser, so that parse() can be called.
mixed parse(object|function(void:string|array(string|mixed)) scanner, void|object action_object)
Parse the input according to the compiled grammar. The last value reduced is returned.
The parser must have been compiled (with compile()) prior to calling this function.
Errors should be throw()n.
The scanner function. It returns the next symbol from the input. It should either return a string (terminal) or an array with a string (terminal) and a mixed (value). EOF is indicated with the empty string.
Object used to resolve those actions that have been specified as strings.
| CLASS Parser.LR.Parser.Item |
An LR(0) item, a partially parsed rule.
Rule Parser.LR.Parser.Item.r
The rule
int Parser.LR.Parser.Item.offset
How long into the rule the parsing has come.
Kernel Parser.LR.Parser.Item.next_state
The state we will get if we shift according to this rule
Item Parser.LR.Parser.Item.master_item
Item representing this one (used for shifts).
multiset(string) Parser.LR.Parser.Item.direct_lookahead
Look-ahead set for this item.
multiset(string) Parser.LR.Parser.Item.error_lookahead
Look-ahead set used for detecting conflicts
multiset(Item) Parser.LR.Parser.Item.relation
Relation to other items (used when compiling).
int Parser.LR.Parser.Item.counter
Depth counter (used when compiling).
int Parser.LR.Parser.Item.number
Item identification number (used when compiling).
int Parser.LR.Parser.Item.item_id
Used to identify the item. Equal to r->number + offset.
| CLASS Parser.LR.Parser.Kernel |
Implements an LR(1) state
multiset(Rule) Parser.LR.Parser.Kernel.rules
Used to check if a rule already has been added when doing closures.
array(Item) Parser.LR.Parser.Kernel.items
Contains the items in this state.
mapping(int:Item) Parser.LR.Parser.Kernel.item_id_to_item
Used to lookup items given rule and offset
mapping(int:multiset(Item)) Parser.LR.Parser.Kernel.symbol_items
Contains the items whose next symbol is this non-terminal.
mapping(int|string:Kernel|Rule) Parser.LR.Parser.Kernel.action
The action table for this state
object(kernel) SHIFT to this state on this symbol.
object(rule) REDUCE according to this rule on this symbol.
multiset Parser.LR.Parser.Kernel.closure_set
The symbols that closure has been called on.
void add_item(Item i)
Add an item to the state.
void closure(int nonterminal)
Make the closure of this state.
Nonterminal to make the closure on.
multiset(int|string) goto_set()
Make the goto-set of this state.
Kernel do_goto(int|string symbol)
Generates the state reached when doing goto on the specified symbol. i.e. it compiles the LR(0) state.
Symbol to make goto on.
| CLASS Parser.LR.Parser.StateQueue |
This is a queue, which keeps the elements even after they are retrieved.
int Parser.LR.Parser.StateQueue.head
Index of the head of the queue.
int Parser.LR.Parser.StateQueue.tail
Index of the tail of the queue.
array(Kernel) Parser.LR.Parser.StateQueue.arr
The queue itself.
Kernel push(Kernel state)
Pushes the state on the queue.
State to push.
Kernel next()
Return the next state from the queue.
| Module Parser.LR.GrammarParser |
This module generates an LR parser from a grammar specified according to the following grammar:
directives : directive ;
directives : directives directive ;
directive : declaration ;
directive : rule ;
declaration : "%token" terminals ";" ;
rule : nonterminal ":" symbols ";" ;
rule : nonterminal ":" symbols action ";" ;
symbols : symbol ;
symbols : symbols symbol ;
terminals : terminal ;
terminals : terminals terminal ;
symbol : nonterminal ;
symbol : "string" ;
action : "{" "identifier" "}" ;
nonterminal : "identifier" ;
terminal : "string";
int Parser.LR.GrammarParser.lr_error
Error code from the parsing.
Parser make_parser(string str, object|void m)
Compiles the parser-specification given in the first argument. Named actions are taken from the object if available, otherwise left as is.
Returns error-code in both GrammarParser.error and return_value->lr_error.
int|Parser make_parser_from_file(string fname, object|void m)
Compiles the file specified in the first argument into an LR parser.
make_parser
| Module Parser.XML |
string autoconvert(string xml)
| CLASS Parser.XML.Validating |
Validating XML parser.
Validates an XML file according to a DTD.
cf http://wwww.w3.org/TR/REC-xml/
$Id: Validating.pike,v 1.20 2008/12/01 10:03:42 grubba Exp $
inherit .Simple : Simple
Extends the Simple XML parser.
int isname(string s)
Check if s is a valid Name.
int isnmtoken(string s)
Check if s is a valid Nmtoken.
int isnames(string s)
Check if s is a valid list of Names.
int isnmtokens(string s)
Check if s is a valid list of Nmtokens.
string get_external_entity(string sysid, string|void pubid, mapping|__deprecated__(int)|void info, mixed ... extra)
Get an external entity.
Called when a <!DOCTYPE> with a SYSTEM identifier is encountered, or when an entity reference needs expanding.
The SYSTEM identifier.
The PUBLIC identifier (if any).
The callbackinfo mapping containing the current parser state.
The extra arguments as passed to parse() or parse_dtd() .
Returns a string with a DTD fragment on success.
Returns 0 (zero) on failure.
Returning zero will cause the validator to report an error.
In Pike 7.7 and earlier info had the value 0 (zero).
The default implementation always returns 0 (zero).
Override this function to provide other behaviour.
parse() , parse_dtd()
mixed validate(string kind, string name, mapping attributes, array|string contents, mapping(string:mixed) info, function(string:mixed) callback, array(mixed) extra)
The validation callback function.
::parse()
array parse(string data, string|function(string:mixed) callback, mixed ... extra)
Document this function
array parse_dtd(string data, string|function(string:mixed) callback, mixed ... extra)
Document this function
| CLASS Parser.XML.Validating.Element |
XML Element node.
| CLASS Parser.XML.Simple |
array parse(string xml, string context, function cb, mixed ... extra_args)
array parse(string xml, function cb, mixed ... extra_args)
The context argument was introduced in Pike 7.8.
mixed parse_dtd(string dtd, string context, function cb, mixed ... extras)
mixed parse_dtd(string dtd, function cb, mixed ... extras)
The context argument was introduced in Pike 7.8.
string lookup_entity(string entity)
Returns the verbatim expansion of the entity.
Added in Pike 7.7.
void define_entity_raw(string entity, string raw)
Define an entity or an SMEG.
Entity name, or SMEG name (if preceeded by a "%").
Verbatim expansion of the entity.
define_entity()
void define_entity(string entity, string s, function cb, mixed ... extras)
Define an entity or an SMEG.
Entity name, or SMEG name (if preceeded by a "%").
Expansion of the entity. Entity evaluation will be performed.
define_entity_raw()
void allow_rxml_entities(int(0..1) yes_no)
void compat_allow_errors(string version)
Set whether the parser should allow certain errors for compatibility with earlier versions. version can be:
|
version can also be zero to enable all error checks.
| CLASS Parser.XML.Simple.Context |
mixed parse_xml()
mixed parse_dtd()
string parse_entity()
void push_string(string s)
void push_string(string s, string context)
Add a string to parse at the current position.
String to insert at the current parsing position.
Optional context used to refer to the inserted string.
This is typically an URL, but may also be an entity
(preceeded by an "&") or a SMEG reference
(preceeded by a "%").
Not used by the XML parser as such, but is simply
passed into the callbackinfo mapping as
the field "context" where it can be useful
for eg resolving relative URLs when parsing DTDs,
or for determining where errors occur.
The context argument was introduced in Pike 7.8.
void Parser.XML.Simple.Context(string s, string context, int flags, function cb, mixed ... extra_args)
void Parser.XML.Simple.Context(string s, int flags, function cb, mixed ... extra_args)
These two arguments are passed along to push_string() .
Parser flags.
Callback function. This function gets called at various stages during the parsing.
The context argument was introduced in Pike 7.8.
| Module Parser.XML.NSTree |
A namespace aware version of Parser.XML.Tree. This implementation does as little validation as possible, so e.g. you can call your namespace xmlfoo without complaints.
inherit Parser.XML.Tree : Tree
NSNode parse_input(string data, void|string default_ns)
Takes a XML string data and produces a namespace node tree. If default_ns is given, it will be used as the default namespace.
Throws an error when an error is encountered during XML parsing.
string visualize(Node n, void|string indent)
Makes a visualization of a node graph suitable for printing out on a terminal.
> object x = parse_input("<a><b><c/>d</b><b><e/><f>g</f></b></a>"); > write(visualize(x)); Node(ROOT) NSNode(ELEMENT,"a") NSNode(ELEMENT,"b") NSNode(ELEMENT,"c") NSNode(TEXT) NSNode(ELEMENT,"b") NSNode(ELEMENT,"e") NSNode(ELEMENT,"f") NSNode(TEXT) Result 1: 201
| CLASS Parser.XML.NSTree.NSNode |
Namespace aware node.
inherit Node : Node
string get_ns()
Returns the namespace in which the current element is defined in.
string get_default_ns()
Returns the default namespace in the current scope.
mapping(string:string) get_defined_nss()
Returns a mapping with all the namespaces defined in the current scope, except the default namespace.
The returned mapping is the same as the one in the node, so destructive changes will affect the node.
mapping(string:string) get_ns_attributes(string namespace)
Returns the attributes in this node that is declared in the provided namespace.
mapping(string:mapping(string:string)) get_ns_attributes()
Returns all the attributes in all namespaces that is associated with this node.
The returned mapping is the same as the one in the node, so destructive changes will affect the node.
void add_namespace(string ns, void|string symbol, void|int(0..1) chain)
Adds a new namespace to this node. The preferred symbol to use to identify the namespace can be provided in the symbol argument. If chain is set, no attempts to overwrite an already defined namespace with the same identifier will be made.
mapping(string:string) diff_namespaces()
Returns the difference between this nodes and its parents namespaces.
string get_xml_name()
Returns the element name as it occurs in xml files. E.g. "zonk:name" for the element "name" defined in a namespace denoted with "zonk". It will look up a symbol for the namespace in the symbol tables for the node and its parents. If none is found a new label will be generated by hashing the namespace.
void remove_child(NSNode child)
The remove_child is a not updated to take care of name space issues. To properly remove all the parents name spaces from the chid, call remove_node in the child.
| Module Parser.XML.Tree |
XML parser that generates node-trees.
Has some support for XML namespaces http://www.w3.org/TR/REC-xml-names/ RFC 2518 23.4.
This module defines two sets of node trees; the SimpleNode -based, and the Node -based. The main difference between the two, is that the Node -based trees have parent pointers, which tend to generate circular data references and thus garbage.
There are some more subtle differences between the two. Please read the documentation carefully.
constant Parser.XML.Tree.STOP_WALK
constant Parser.XML.Tree.XML_ROOT
constant Parser.XML.Tree.XML_ELEMENT
constant Parser.XML.Tree.XML_TEXT
constant Parser.XML.Tree.XML_HEADER
constant Parser.XML.Tree.XML_PI
constant Parser.XML.Tree.XML_COMMENT
constant Parser.XML.Tree.XML_DOCTYPE
constant Parser.XML.Tree.XML_ATTR
Attribute nodes are created on demand
constant Parser.XML.Tree.DTD_ENTITY
constant Parser.XML.Tree.DTD_ELEMENT
constant Parser.XML.Tree.DTD_ATTLIST
constant Parser.XML.Tree.DTD_NOTATION
constant Parser.XML.Tree.XML_NODE
string text_quote(string data)
Quotes the string given in data by escaping &, < and >.
string roxen_text_quote(string data)
Quotes strings just like text_quote , but entities in the form &foo.bar; will not be quoted.
string attribute_quote(string data)
Quotes the string given in data by escaping &, <, >, ' and ".
string roxen_attribute_quote(string data)
Quotes strings just like attribute_quote , but entities in the form &foo.bar; will not be quoted.
SimpleRootNode simple_parse_input(string data, void|mapping predefined_entities, ParseFlags|void flags, string|void default_namespace)
Takes an XML string and produces a SimpleNode tree.
SimpleRootNode simple_parse_file(string path, void|mapping predefined_entities, ParseFlags|void flags, string|void default_namespace)
Loads the XML file path , creates a SimpleNode tree representation and returns the root node.
RootNode parse_input(string data, void|int(0..1) no_fallback, void|int(0..1) force_lowercase, void|mapping(string:string) predefined_entities, void|int(0..1) parse_namespaces, ParseFlags|void flags)
Takes an XML string and produces a node tree.
flags is not used for PARSE_WANT_ERROR_CONTEXT , PARSE_FORCE_LOWERCASE or PARSE_ENABLE_NAMESPACES since they are covered by the separate flag arguments.
Node parse_file(string path, int(0..1)|void parse_namespaces)
Loads the XML file path , creates a node tree representation and returns the root node.
| ENUM Parser.XML.Tree.ParseFlags |
Flags used together with simple_parse_input() and simple_parse_file() .
| CLASS Parser.XML.Tree.XMLNSParser |
Namespace aware parser.
mapping(string:string) Enter(mapping(string:string) attrs)
Check attrs for namespaces.
Returns the namespace expanded version of attrs .
| CLASS Parser.XML.Tree.AbstractSimpleNode |
Base class for nodes.
array(AbstractSimpleNode) get_children()
Returns all the nodes children.
int count_children()
Returns the number of children of the node.
AbstractSimpleNode low_clone()
Returns an initialized copy of the node.
The returned node has no children.
AbstractSimpleNode clone()
Returns a clone of the sub-tree rooted in the node.
AbstractSimpleNode get_last_child()
Returns the last child node or zero.
AbstractSimpleNode `[](int pos)
The [] operator indexes among the node children, so
node[0] returns the first node and node[-1] the last.
The [] operator will select a node from all the nodes children, not just its element children.
AbstractSimpleNode add_child(AbstractSimpleNode c)
Adds the given node to the list of children of this node. The new node is added last in the list.
The return value differs from the one returned by Node()->add_child() .
The current node.
AbstractSimpleNode add_child_before(AbstractSimpleNode c, AbstractSimpleNode old)
Adds the node c to the list of children of this node. The node is added before the node old , which is assumed to be an existing child of this node. The node is added last if old is zero.
The current node.
AbstractSimpleNode add_child_after(AbstractSimpleNode c, AbstractSimpleNode old)
Adds the node c to the list of children of this node. The node is added before the node old , which is assumed to be an existing child of this node. The node is added first if old is zero.
The current node.
void remove_child(AbstractSimpleNode c)
Removes all occurrences of the provided node from the list of children of this node.
void replace_children(array(AbstractSimpleNode) children)
Replaces the nodes children with the provided ones.
AbstractSimpleNode replace_child(AbstractSimpleNode old, AbstractSimpleNode new)
Replaces the first occurrence of the old node child with the new node child.
The return value differs from the one returned by Node()->replace_child() .
Returns the current node on success, and 0 (zero)
if the node old wasn't found.
void zap_tree()
Destruct the tree recursively. When the inheriting AbstractNode or Node is used, which have parent pointers, this function should be called for every tree that no longer is in use to avoid frequent garbage collector runs.
int walk_preorder(function(AbstractSimpleNode:int|void) callback, mixed ... args)
Traverse the node subtree in preorder, root node first, then subtrees from left to right, calling the callback function for every node. If the callback function returns STOP_WALK the traverse is promptly aborted and STOP_WALK is returned.
int walk_preorder_2(function(AbstractSimpleNode:int|void) cb_1, function(AbstractSimpleNode:int|void) cb_2, mixed ... args)
Traverse the node subtree in preorder, root node first, then subtrees from left to right. For each node we call cb_1 before iterating through children, and then cb_2 (which always gets called even if the walk is aborted earlier). If the callback function returns STOP_WALK the traverse decend is aborted and STOP_WALK is returned once all waiting cb_2 functions have been called.
int walk_inorder(function(AbstractSimpleNode:int|void) callback, mixed ... args)
Traverse the node subtree in inorder, left subtree first, then root node, and finally the remaining subtrees, calling the function callback for every node. If the function callback returns STOP_WALK the traverse is promptly aborted and STOP_WALK is returned.
int walk_postorder(function(AbstractSimpleNode:int|void) callback, mixed ... args)
Traverse the node subtree in postorder, first subtrees from left to right, then the root node, calling the function callback for every node. If the function callback returns STOP_WALK the traverse is promptly aborted and STOP_WALK is returned.
int iterate_children(function(AbstractSimpleNode:int|void) callback, mixed ... args)
Iterates over the nodes children from left to right, calling the function callback for every node. If the callback function returns STOP_WALK the iteration is promptly aborted and STOP_WALK is returned.
array(AbstractSimpleNode) get_descendants(int(0..1) include_self)
Returns a list of all descendants in document order. Includes this node if include_self is set.
| CLASS Parser.XML.Tree.AbstractNode |
Base class for nodes with parent pointers.
inherit AbstractSimpleNode : AbstractSimpleNode
void set_parent(AbstractNode parent)
Sets the parent node to parent .
AbstractNode get_parent()
Returns the parent node.
AbstractNode low_clone()
Returns an initialized copy of the node.
The returned node has no children, and no parent.
AbstractNode clone(void|int(-1..1) direction)
Clones the node, optionally connected to parts of the tree. If direction is -1 the cloned nodes parent will be set, if direction is 1 the clone nodes childen will be set.
AbstractNode get_root()
Follows all parent pointers and returns the root node.
AbstractNode add_child(AbstractNode c)
Adds the node c to the list of children of this node. The node is added before the node old , which is assumed to be an existing child of this node. The node is added first if old is zero.
Returns the new child node, NOT the current node.
The new child node is returned.
AbstractSimpleNode add_child_before(AbstractSimpleNode c, AbstractSimpleNode old)
Adds the node c to the list of children of this node. The node is added before the node old , which is assumed to be an existing child of this node. The node is added last if old is zero.
The current node.
AbstractSimpleNode add_child_after(AbstractSimpleNode c, AbstractSimpleNode old)
Adds the node c to the list of children of this node. The node is added before the node old , which is assumed to be an existing child of this node. The node is added first if old is zero.
The current node.
AbstractNode tmp_add_child(AbstractNode c)
AbstractNode tmp_add_child_before(AbstractNode c, AbstractNode old)
AbstractNode tmp_add_child_after(AbstractNode c, AbstractNode old)
Variants of add_child , add_child_before and add_child_after that doesn't set the parent pointer in the newly added children.
This is useful while building a node tree, to get efficient refcount garbage collection if the build stops abruptly. fix_tree has to be called on the root node when the building is done.
void fix_tree()
Fix all parent pointers recursively in a tree that has been built with tmp_add_child .
void remove_child(AbstractNode c)
Removes all occurrences of the provided node from the called nodes list of children. The removed nodes parent reference is set to null.
void remove_node()
Removes this node from its parent. The parent reference is set to null.
void replace_children(array(AbstractNode) children)
Replaces the nodes children with the provided ones. All parent references are updated.
AbstractNode replace_child(AbstractNode old, AbstractNode new)
Replaces the first occurrence of the old node child with the new node child. All parent references are updated.
The returned value is NOT the current node.
Returns the new child node.
AbstractNode replace_node(AbstractNode new)
Replaces this node with the provided one.
Returns the new node.
array(AbstractNode) get_preceding_siblings()
Returns all preceding siblings, i.e. all siblings present before this node in the parents children list.
array(AbstractNode) get_following_siblings()
Returns all following siblings, i.e. all siblings present after this node in the parents children list.
array(AbstractNode) get_siblings()
Returns all siblings, including this node.
array(AbstractNode) get_ancestors(int(0..1) include_self)
Returns a list of all ancestors, with the top node last. The list will start with this node if include_self is set.
array(AbstractNode) get_preceding()
Returns all preceding nodes, excluding this nodes ancestors.
array(AbstractNode) get_following()
Returns all the nodes that follows after the current one.
| CLASS Parser.XML.Tree.VirtualNode |
Node in XML tree
mapping(string:string) get_attributes()
Returns this nodes attributes, which can be altered destructivly to alter the nodes attributes.
mapping get_short_attributes()
Returns this nodes name-space adjusted attributes.
set_short_namespaces() must have been called before calling this function.
int get_node_type()
Returns the node type. See defined node type constants.
string get_text()
Returns text content in node.
int get_doc_order()
void set_doc_order(int o)
string get_tag_name()
Returns the name of the element node, or the nearest element above if an attribute node.
string get_any_name()
Return name of tag or name of attribute node.
void set_tag_name(string name)
Change the tag name destructively. Can only be used on element and processing-instruction nodes.
string get_namespace()
Return the (resolved) namespace for this node.
string get_full_name()
Return fully qualified name of the element node.
void Parser.XML.Tree.VirtualNode(int type, string name, mapping attr, string text)
string value_of_node()
If the node is an attribute node or a text node, its value is returned. Otherwise the child text nodes are concatenated and returned.
AbstractNode get_first_element(string|void name, int(0..1)|void full)
Returns the first element child to this node.
If provided, the first element child with that name is returned.
If specified, name matching will be done against the full name.
Returns the first matching node, and 0 if no such node was found.
array(AbstractNode) get_elements(string|void name, int(0..1)|void full)
Returns all element children to this node.
If provided, only elements with that name is returned.
If specified, name matching will be done against the full name.
Returns an array with matching nodes.
mixed cast(string to)
It is possible to cast a node to a string, which will return render_xml() for that node.
string render_xml(void|int(0..1) preserve_roxen_entities, void|mapping(string:string) namespace_lookup)
Creates an XML representation of the node sub tree. If the flag preserve_roxen_entities is set, entities on the form &foo.bar; will not be escaped.
Mapping from namespace prefix to namespace symbol prefix.
void render_to_file(Stdio.File f, void|int(0..1) preserve_roxen_entities)
Creates an XML representation fo the node sub tree and streams the output to the file f . If the flag preserve_roxen_entities is set, entities on the form &foo.bar; will not be escaped.
| CLASS Parser.XML.Tree.SimpleNode |
XML node without parent pointers and attribute nodes.
inherit AbstractSimpleNode : AbstractSimpleNode
inherit VirtualNode : VirtualNode
| CLASS Parser.XML.Tree.Node |
XML node with parent pointers.
inherit AbstractNode : AbstractNode
inherit VirtualNode : VirtualNode
string get_tag_name()
Returns the name of the element node, or the nearest element above if an attribute node.
string get_attr_name()
Returns the name of the attribute node.
array(Node) get_attribute_nodes()
Creates and returns an array of new nodes; they will not be added as proper children to the parent node, but the parent link in the nodes are set so that upwards traversal is made possible.
| CLASS Parser.XML.Tree.XMLParser |
Mixin for parsing XML.
| CLASS Parser.XML.Tree.SimpleRootNode |
The root node of an XML-tree consisting of SimpleNode s.
inherit SimpleNode : SimpleNode
inherit XMLParser : XMLParser
SimpleElementNode get_element_by_id(string id, int|void force)
Find the element with the specified id.
The XML id of the node to search for.
Force a regeneration of the id lookup cache. Needed the first time after the node tree has been modified by adding or removing element nodes, or by changing the id attribute of an element node.
Returns the element node with the specified id if any. Returns UNDEFINED otherwise.
flush_node_id_cache
void flush_node_id_cache()
Clears the node id cache built and used by get_element_by_id .
| CLASS Parser.XML.Tree.RootNode |
The root node of an XML-tree consisting of Node s.
inherit Node : Node
inherit XMLParser : XMLParser
ElementNode get_element_by_id(string id, int|void force)
Find the element with the specified id.
The XML id of the node to search for.
Force a regeneration of the id lookup cache. Needed the first time after the node tree has been modified by adding or removing element nodes, or by changing the id attribute of an element node.
Returns the element node with the specified id if any. Returns UNDEFINED otherwise.
flush_node_id_cache
void flush_node_id_cache()
Clears the node id cache built and used by get_element_by_id .
| Module Parser.XML.SloppyDOM |
A somewhat DOM-like library that implements lazy generation of the node tree, i.e. it's generated from the data upon lookup. There's also a little bit of XPath evaluation to do queries on the node tree.
Implementation note: This is generally more pragmatic than Parser.XML.DOM , meaning it's not so pretty and compliant, but more efficient.
Implementation status: There's only enough implemented to parse a node tree from source and access it, i.e. modification functions aren't implemented. Data hiding stuff like NodeList and NamedNodeMap is not implemented, partly since it's cumbersome to meet the "live" requirement. Also, Parser.HTML is used in XML mode to parse the input. Thus it's too error tolerant to be XML compliant, and it currently doesn't handle DTD elements, like "<!DOCTYPE", or the XML declaration (i.e. "<?xml version='1.0'?>".
Document parse(string source, void|int raw_values)
Normally entities are decoded, and Node.xml_format will encode them again. If raw_values is nonzero then all text and attribute values are instead kept in their original form.
| CLASS Parser.XML.SloppyDOM.Node |
Basic node.
string get_text_content()
If the raw_values flag is set in the owning document, the text is returned with entities and CDATA blocks intact.
parse
mapping(string:string)|Node|array(mapping(string:string)|Node)|string simple_path(string path, void|int xml_format)
Access a node or a set of nodes through an expression that is a subset of an XPath RelativeLocationPath in abbreviated form.
That means one or more Steps separated by "/" or "//". A Step consists of an AxisSpecifier followed by a NodeTest and then optionally by one or more Predicate's.
"/" before a Step causes it to be matched only against the immediate children of the node(s) selected by the previous Step. "//" before a Step causes it to be matched against any children in the tree below the node(s) selected by the previous Step. The initial selection before the first Step is this element.
The currently allowed AxisSpecifier NodeTest combinations are:
name to select all elements with the given name. The name can be "*" to select all.
@name to select all attributes with the given name. The name can be "*" to select all.
comment() to select all comments.
text() to select all text and CDATA blocks. Note that all entity references are also selected, under the assumption that they would expand to text only.
processing-instruction("name") to select all processing instructions with the given name. The name can be left out to select all. Either ' or " may be used to delimit the name. For compatibility, it can also occur without surrounding quotes.
node() to select all nodes, i.e. the whole content of an element node.
. to select the currently selected element itself.
A Predicate is on the form [PredicateExpr] where PredicateExpr currently can be in any of the following forms:
An integer indexes one item in the selected set, according to the document order. A negative index counts from the end of the set.
A RelativeLocationPath as specified above. It's executed for each element in the selected set and those where it yields an empty result are filtered out while the rest remain in the set.
A RelativeLocationPath as specified above followed by ="value". The path is executed for each element in the selected set and those where the text result of it is equal to the given value remain in the set. Either ' or " may be used to delimit the value.
If xml_format is nonzero, the return value is an xml formatted string of all the matched nodes, in document order. Otherwise the return value is as follows:
Attributes are returned as one or more index/value pairs in a mapping. Other nodes are returned as the node objects. If the expression is on a form that can give at most one answer (i.e. there's a predicate with an integer index) then a single mapping or node is returned, or zero if there was no match. If the expression can give more answers then the return value is an array containing zero or more attribute mappings and/or nodes. The array follows document order.
Not DOM compliant.
string xml_format()
Returns the formatted XML that corresponds to the node tree.
Not DOM compliant.
| CLASS Parser.XML.SloppyDOM.NodeWithChildElements |
Node with child elements.
inherit NodeWithChildren : NodeWithChildren
array(Element) get_elements(string name)
Lightweight variant of get_elements_by_tag_name that returns a simple array instead of a fancy live NodeList.
Not DOM compliant.
array(Element) get_descendant_elements()
Returns all descendant elements in document order.
Not DOM compliant.
array(Node) get_descendant_nodes()
Returns all descendant nodes (except attribute nodes) in document order.
Not DOM compliant.
| CLASS Parser.XML.SloppyDOM.Document |
The node tree is very likely a cyclic structure, so it might be an good idea to destruct it when you're finished with it, to avoid garbage. Destructing the Document object always destroys all nodes in it.
inherit NodeWithChildElements : NodeWithChildElements
array(Element) get_elements(string name)
Note that this one looks among the top level elements, as opposed to get_elements_by_tag_name . This means that if the document is correct, you can only look up the single top level element here.
Not DOM compliant.
int get_raw_values()
Not DOM compliant.
| Module Parser.Pike |
This module parses and tokenizes Pike source code.
inherit "C.pmod"
array(string) split(string data, void|mapping state)
Splits the data string into an array of tokens. An additional element with a newline will be added to the resulting array of tokens. If the optional argument state is provided the split function is able to pause and resume splitting inside #"" and /**/ tokens. The state argument should be an initially empty mapping, in which split will store its state between successive calls.
| CLASS Parser.Pike.UnterminatedStringError |
Error thrown when an unterminated string token is encountered.
inherit Error.Generic : Generic
string Parser.Pike.UnterminatedStringError.err_str
The string that failed to be tokenized
| Module Parser.C |
array(string) split(string data, void|mapping state)
Splits the data string into an array of tokens. An additional element with a newline will be added to the resulting array of tokens. If the optional argument state is provided the split function is able to pause and resume splitting inside /**/ tokens. The state argument should be an initially empty mapping, in which split will store its state between successive calls.
array(Token) tokenize(array(string) s, void|string file)
Returns an array of Token objects given an array of string tokens.
array(Token|array) group(array(string|Token) tokens, void|mapping(string:string) groupings)
Fold sub blocks of an array of tokens into sub arrays, for grouping purposes.
The token array to fold.
Supplies the tokens marking the boundaries of blocks to fold. The indices of the mapping mark the start of a block, the corresponding values mark where the block ends. The sub arrays will start and end in these tokens. If no groupings mapping is provided, {}, () and [] are used as block boundaries.
array(Token|array) strip_line_statements(array(Token|array) tokens)
Strips off all (preprocessor) line statements from a token array.
array hide_whitespaces(array tokens)
Folds all whitespace tokens into the previous token's trailing_whitespaces.
string simple_reconstitute(array(string|Token|array) tokens)
Reconstitutes the token array into a plain string again; essentially reversing split() and whichever of the tokenize , group and hide_whitespaces methods may have been invoked.
string reconstitute_with_line_numbers(array(string|Token|array) tokens)
Like simple_reconstitute , but adding additional #line n "file" preprocessor statements in the output whereever a new line or file starts.
| CLASS Parser.C.Token |
Represents a C token, along with a selection of associated data and operations.
int Parser.C.Token.line
The line where the token was found.
string Parser.C.Token.text
The actual token.
string Parser.C.Token.file
The file in which the token was found.
string Parser.C.Token.trailing_whitespaces
Trailing whitespaces.
void Parser.C.Token(string text, void|int line, void|string file, void|string trailing_whitespace)
string _sprintf(int how)
If the object is printed as %s it will only output its text contents.
int `==(mixed foo)
Tokens are considered equal if the text contents are equal. It is also possible to compare the Token object with a text string directly.
string `+(string ... s)
A string can be added to the Token, which will be added to the text contents.
string ``+(string ... s)
A string can be added to the Token, which will be added to the text contents.
mixed cast(string to)
It is possible to case a Token object to a string. The text content will be returned.
int|string `[](int a, void|int b)
Characters and ranges may be indexed from the text contents of the token.
| Module Parser.Python |
array(string) split(string data)
Returns the provided string with Python code as an array with tokens.
| Module Standards |
| CLASS Standards.URI |
This class implements URI parsing and resolving of relative references to absolute form, as defined in RFC 2396 and RFC 3986.
string Standards.URI.scheme
Scheme component of URI
string Standards.URI.authority
Authority component of URI (formerly called net_loc, from RFC 2396 known as authority)
string Standards.URI.path
Path component of URI. May be empty, but not undefined.
string Standards.URI.query
Query component of URI. May be 0 if not present.
string Standards.URI.fragment
The fragment part of URI. May be 0 if not present.
string Standards.URI.host
string Standards.URI.user
string Standards.URI.password
Certain classes of URI (e.g. URL) may have these defined
int Standards.URI.port
If no port number is present in URI, but the scheme used has a default port number, this number is put here.
this_program Standards.URI.base_uri
The base URI object, if present
int `==(mixed something)
Compare this URI to something, in a canonical way.
Compare the URI to this
void reparse_uri()
void reparse_uri(URI base_uri)
void reparse_uri(string base_uri)
Reparse the URI with respect to a new base URI. If no base_uri was supplied, the old base_uri is thrown away. The resolving is performed according to the guidelines outlined by RFC 2396, Uniform Resource Identifiers (URI): Generic Syntax.
Set the new base URI to this.
void Standards.URI(URI uri)
void Standards.URI(URI uri, URI base_uri)
void Standards.URI(URI uri, string base_uri)
void Standards.URI(string uri)
void Standards.URI(string uri, URI base_uri)
void Standards.URI(string uri, string base_uri)
When supplied, will root the URI a the given location. This is needed to correctly verify relative URIs, but may be left out otherwise. If left out, and uri is a relative URI, an error is thrown.
When uri is another URI object, the created URI will inherit all properties of the supplied uri except, of course, for its base_uri.
mixed `->=(string property, mixed value)
mixed `[]=(string property, mixed value)
Assign a new value to a property of URI
When any of the following properties are used, properties that depend on them are recalculated: user, password, host, port, authority, base_uri.
The value to assign to property
string|mapping cast(string to)
When cast to string, return the URI (in a canonicalized form). When cast to mapping, return a mapping with scheme, authority, user, password, host, port, path, query, fragment, raw_uri, base_uri as documented above.
string get_path_query()
Returns path and query part of the URI if present.
mapping(string:string) get_query_variables()
Returns the query variables as a mapping(string:string).
void set_query_variables(mapping(string:string) vars)
Sets the query variables from the provided mapping.
void add_query_variable(string name, string value)
Adds the provided query variable to the already existing ones. Will overwrite an existing variable with the same name.
void add_query_variables(mapping(string:string) vars)
Appends the provided set of query variables with the already existing ones. Will overwrite all existing variables with the same names.
string get_http_query()
Return the query part, coded according to RFC 1738.
string get_http_path_query()
Return the path and query part of the URI, coded according to RFC 1738.
| Module Standards.ASN1 |
string encode_der_oid(string dotted_decimal)
Convenience function to convert an oid (object identifier) on
dotted-decimal form (e.g. "1.3.6.1.4.1.1466.115.121.1.38")
to its DER (and hence also BER) encoded form.
decode_der_oid
string decode_der_oid(string der_oid)
Convenience function to convert a DER/BER encoded oid (object identifier) to the human readable dotted-decimal form.
encode_der_oid
| Module Standards.ASN1.Decode |
Decodes a DER object.
.Types.Object der_decode(ADT.struct data, mapping(int:program) types)
an instance of ADT.struct
a mapping from combined tag numbers to classes from or derived from Standards.ASN1.Types . Combined tag numbers may be generated using Standards.ASN1.Types.make_combined_tag .
an object from Standards.ASN1.Types or either Standards.ASN1.Decode.Primitive or Standards.ASN1.Decode.constructed if the type is unknown. Throws an exception if the data could not be decoded.
Handling of implicit and explicit ASN.1 tagging, as well as other context dependence, is next to non_existant.
.Types.Object simple_der_decode(string data)
decode a DER encoded object using universal data types
a DER encoded object
an object from Standards.ASN1.Types or either Standards.ASN1.Decode.Primitive or Standards.ASN1.Decode.constructed if the type is unknown.
| CLASS Standards.ASN1.Decode.Primitive |
Primitive unconstructed ASN1 data type.
inherit Types.Object : Object
string get_der()
int get_combined_tag()
get raw encoded contents of object
int get_tag()
get tag
int get_cls()
get class
| CLASS Standards.ASN1.Decode.Constructed |
Constructed type
inherit Types.Object : Object
string Standards.ASN1.Decode.Constructed.raw
raw encoded contents
array Standards.ASN1.Decode.Constructed.elements
elements of object
int get_tag()
get tag
int get_cls()
get class
| Module Standards.ASN1.Types |
Encodes various asn.1 objects according to the Distinguished Encoding Rules (DER)
int make_combined_tag(int cls, int tag)
Combines tag and class as a single integer, in a somewhat arbitrary way. This works also for tags beyond 31 (although not for tags beyond 2^30.
ASN1 type class
ASN1 type tag
combined tag
Standards.ASN1.Types.extract_tag Standards.ASN1.Types.extract_cls
int extract_tag(int i)
extract ASN1 type tag from a combined tag
Standards.ASN1.Types.make_combined_tag
int extract_cls(int i)
extract ASN1 type class from a combined tag
Standards.ASN1.Types.make_combined_tag
int(1..1) asn1_utf8_valid(string s)
Checks if a Pike string can be encoded with UTF8. That is always the case...
int(0..1) asn1_printable_valid(string s)
Checks if a Pike string can be encoded as a PrintableString .
int(0..1) asn1_teletex_valid(string s)
int(0..1) asn1_broken_teletex_valid(string s)
int(0..1) asn1_IA5_valid(string s)
int(0..0) asn1_universal_valid(string s)
int(0..1) asn1_bmp_valid(string s)
| CLASS Standards.ASN1.Types.Object |
Generic, abstract base class for ASN1 data types.
int get_cls()
Get the class of this object.
The class of this object.
int get_tag()
Get the tag for this object.
The tag for this object.
int get_combined_tag()
Get the combined tag (tag + class) for this object.
the combined tag header
string get_der()
Get the DER encoded version of this object.
DER encoded representation of this object.
| CLASS Standards.ASN1.Types.Compound |
Compound object primitive
inherit Object : Object
array(Object) Standards.ASN1.Types.Compound.elements
contents of compound object, elements are from Standards.ASN1.Types
| CLASS Standards.ASN1.Types.String |
string object primitive
inherit Object : Object
string Standards.ASN1.Types.String.value
value of object
| CLASS Standards.ASN1.Types.Boolean |
boolean object
inherit Object : Object
int Standards.ASN1.Types.Boolean.value
value of object
| CLASS Standards.ASN1.Types.Integer |
Integer object All integers are represented as bignums, for simplicity
inherit Object : Object
Gmp.mpz Standards.ASN1.Types.Integer.value
value of object
| CLASS Standards.ASN1.Types.Enumerated |
Enumerated object
inherit Integer : Integer
| CLASS Standards.ASN1.Types.BitString |
Bit string object
inherit Object : Object
string Standards.ASN1.Types.BitString.value
value of object
this_program set_from_ascii(string s)
Set the bitstring value as a string with "1" and
"0".
int set_length(int len)
Sets the length of the bit string to len number of bits.
| CLASS Standards.ASN1.Types.OctetString |
Octet string object
inherit String : String
| CLASS Standards.ASN1.Types.Null |
Null object
inherit Object : Object
| CLASS Standards.ASN1.Types.Identifier |
Object identifier object
inherit Object : Object
array(int) Standards.ASN1.Types.Identifier.id
value of object
this_program append(int ... args)
Returns a new Identifier object with args appended to the ID path.
| CLASS Standards.ASN1.Types.UTF8String |
UTF8 string object
Character set: ISO/IEC 10646-1 (compatible with Unicode).
Variable width encoding, see rfc2279.
inherit String : String
| CLASS Standards.ASN1.Types.Sequence |
Sequence object
inherit Compound : Compound
| CLASS Standards.ASN1.Types.Set |
Set object
inherit Compound : Compound
| CLASS Standards.ASN1.Types.PrintableString |
PrintableString object
inherit String : String
| CLASS Standards.ASN1.Types.TeletexString |
TeletexString object
Avoid this one; it seems to be common that this type is used to label strings encoded with the ISO 8859-1 character set (use asn1_broken_teletex_string for that). From http://www.mindspring.com/~asn1/nlsasn.htm:
/.../ Types GeneralString, VideotexString, TeletexString (T61String), and GraphicString exist in earlier versions [pre-1994] of ASN.1. They are considered difficult to use correctly by applications providing national language support. Varying degrees of application support for T61String values seems to be most common in older applications. Correct support is made more difficult, as character values available in type T61String have changed with the addition of new register entries from the 1984 through 1997 versions.
This implementation is based on the description of T.61 and T.51 in "Some functions for representing T.61 characters from the X.500 Directory Service in ISO 8859 terminals (Version 0.2. July 1994.)" by Enrique Silvestre Mora (mora@si.uji.es), Universitat Jaume I, Spain, found in the package ftp://pereiii.uji.es/pub/uji-ftp/unix/ldap/iso-t61.translation.tar.Z
The translation is only complete for 8-bit latin 1 strings. It encodes strictly to T.61, but decodes from the superset T.51.
CCITT Recommendation T.61 is also known as ISO-IR 103:1985 (graphic characters) and ISO-IR 106:1985 and ISO-IR 107:1985 (control characters).
Locale.Charset
inherit String : String
| CLASS Standards.ASN1.Types.BrokenTeletexString |
(broken) TeletexString object
Encodes and decodes latin1, but labels it TeletexString, as is common in many broken programs (e.g. Netscape 4.0X).
inherit String : String
| CLASS Standards.ASN1.Types.IA5String |
IA5 String object
Character set: ASCII. Fixed width encoding with 1 octet per character.
inherit String : String
| CLASS Standards.ASN1.Types.VisibleString |
inherit String : String
| CLASS Standards.ASN1.Types.UTC |
inherit String : String
| CLASS Standards.ASN1.Types.UniversalString |
Universal String object
Character set: ISO/IEC 10646-1 (compatible with Unicode). Fixed width encoding with 4 octets per character.
The encoding is very likely UCS-4, but that's not yet verified.
inherit OctetString : OctetString
| CLASS Standards.ASN1.Types.BMPString |
BMP String object
Character set: ISO/IEC 10646-1 (compatible with Unicode). Fixed width encoding with 2 octets per character.
FIXME: The encoding is very likely UCS-2, but that's not yet verified.
inherit OctetString : OctetString
| CLASS Standards.ASN1.Types.MetaExplicit |
Meta-instances handle a particular explicit tag and set of types.
document me!
| Module Standards.XML |
| Module Standards.XML.Wix |
Helper module for generating Windows Installer XML structures.
Parser.XML.Tree.SimpleNode
WixNode get_module_xml(Directory dir, string id, string version, string|void manufacturer, string|void description, string|void guid, string|void comments, string|void installer_version)
Modifies dir if it contains files at the root level.
| Module Standards.PKCS |
| Module Standards.PKCS.Certificate |
Handle PKCS-6 and PKCS-10 certificates and certificate requests.
Sequence build_distinguished_name(mapping(string:object) ... args)
Sequence get_certificate_issuer(string cert)
Return the certificate issuer RDN from a certificate string.
A string containing an X509 certificate.
Note that the certificate normally must be decoded using MIME.decode_base64 .
An Standards.ASN1.Sequence object containing the certificate issuer Distinguished Name (DN).
string get_dn_string(Sequence dnsequence)
Converts an RDN (relative distinguished name) Seqeunce object to a human readable string in X500 format.
A string containing an X509 certificate.
Note that the certificate normally must be decoded using MIME.decode_base64 .
A string containing the certificate issuer Distinguished Name (DN) in human readable X500 format.
We don't currently handle attributes with multiple values, not all attribute types are understood.
Sequence get_certificate_subject(string cert)
Return the certificate subject RDN from a certificate string.
A string containing an X509 certificate.
Note that the certificate normally must be decoded using MIME.decode_base64 .
An Standards.ASN1.Sequence object containing the certificate subject Distinguished Name (DN).
| Module Standards.PKCS.RSA |
RSA operations and types as described in PKCS-1.
string public_key(Crypto.RSA rsa)
Create a DER-coded RSAPublicKey structure
Crypto.RSA object
ASN1 coded RSAPublicKey structure
string private_key(Crypto.RSA rsa)
Create a DER-coded RSAPrivateKey structure
Crypto.RSA object
ASN1 coded RSAPrivateKey structure
Crypto.RSA parse_public_key(string key)
Decode a DER-coded RSAPublicKey structure
RSAPublicKey provided in ASN1 encoded format
Crypto.RSA object
Crypto.RSA parse_private_key(string key)
Decode a DER-coded RSAPrivateKey structure
RSAPrivateKey provided in ASN1 encoded format
Crypto.RSA object
| Module Standards.PKCS.DSA |
DSA operations as defined in RFC-2459.
Sequence algorithm_identifier(Crypto.DSA|void dsa)
string public_key(Crypto.DSA dsa)
string private_key(Crypto.DSA dsa)
Crypto.DSA parse_private_key(string key)
| Module Standards.PKCS.CSR |
Handling of Certifikate Signing Requests (PKCS-10)
Sequence build_csr(Crypto.RSA rsa, object name, mapping(string:array(object)) attributes)
| Module Standards.PKCS.Signature |
string build_digestinfo(string msg, Crypto.Hash hash)
Construct a PKCS-1 digestinfo.
message to digest
crypto hash object such as Crypto.SHA1 or Crypto.MD5
Crypto.RSA()->sign, Crypto.RSA()->cooked_sign
| Module Standards.PKCS.Identifiers |
Various ASN.1 identifiers used by PKCS.
| Module Standards.ISO639_2 |
string get_language(string code)
Look up the language name given an ISO 639-2 code in lower case. It will first be looked up in the ISO 639-2/T table and then in ISO 639-2/B if the first lookup failed. Returns zero typed zero on failure.
string get_language_t(string code)
Look up the language name given an ISO 639-2/T code in lower case. Returns zero typed zero on failure.
string get_language_b(string code)
Look up the language name given an ISO 639-2/B code in lower case. Returns zero typed zero on failure.
mapping(string:string) list_languages()
Return a mapping from ISO 639-2/T + ISO 639-2/B codes to language names.
mapping(string:string) list_languages_t()
Return a mapping from ISO 639-2/T codes to language names.
mapping(string:string) list_languages_b()
Return a mapping from ISO 639-2/B codes to language names.
string convert_b_to_t(string code)
Converts an ISO 639-2/B code to an ISO 639-2/T code.
string convert_t_to_b(string code)
Converts an ISO 639-2/T code to an ISO 639-2/B code.
string map_639_1(string code)
Look up the ISO 639-2/T code given an ISO 639-1 code in lower case.
string map_to_639_1(string code)
Look up the ISO 639-1 code given an ISO 639-2/T code in lower case.
mapping(string:string) list_639_1()
Return a mapping from ISO 639-1 code to ISO 639-2/T code.
| Module Standards.UUID |
Support for Universal Unique Identifiers (UUID) and Globally Unique Identifiers (GUID).
RFC4122: A Universally Unique IDentifier (UUID) URN Namespace ITU-T X.667: Generation and registration of Universally Unique Identifiers (UUIDs) and their use as ASN.1 object identifier components
array(int) get_clock_state()
Returns the internal clock state. Can be used for persistent storage when an application is terminated.
set_clock_state
void set_clock_state(int last_time, int seq)
Sets the internal clock state.
get_clock_state
UUID make_version1(int node)
Creates a new version 1 UUID.
Either the 48 bit IEEE 802 (aka MAC) address of the system or -1.
UUID make_version3(string name, string|UUID namespace)
Creates a version 3 UUID with a name string and a binary representation of a name space UUID.
UUID make_version4()
Creates a version 4 (random) UUID.
UUID make_version5(string name, string|UUID namespace)
Creates a version 5 UUID with a name string and a binary representation of a name space UUID.
string format_uuid(string uuid)
Returns the string representation of the binary UUID uuid .
string parse_uuid(string uuid)
Returns the binary representation of the UUID uuid .
constant Standards.UUID.Nil_UUID
The Nil UUID.
constant Standards.UUID.NameSpace_DNS
Name space UUID for DNS.
constant Standards.UUID.NameSpace_URL
Name space UUID for URL.
constant Standards.UUID.NameSpace_OID
Name space UUID for OID.
constant Standards.UUID.NameSpace_X500
Name space UUID for X500.
UUID make_null()
Creates a null UUID object.
UUID make_dns(string name)
Creates a DNS UUID with the given DNS name.
UUID make_url(string name)
Creates a URL UUID with the given URL.
UUID make_oid(string name)
Creates an OID UUID with the given OID.
UUID make_x500(string name)
Creates an X500 UUID with the gived X500 address.
UUID make_dns(string name)
Creates a DNS UUID with the given DNS name.
UUID make_url(string name)
Creates a URL UUID with the given URL.
UUID make_oid(string name)
Creates an OID UUID with the given OID.
UUID make_x500(string name)
Creates an X500 UUID with the gived X500 address.
| CLASS Standards.UUID.UUID |
Represents an UUID
int Standards.UUID.UUID.timestamp
60 bit value representing the time stamp.
int posix_time()
Returns the posix time of the UUID.
int Standards.UUID.UUID.version
The version of the UUID.
string str_version()
Returns a string representation of the version, e.g.
"Name-based (MD5)".
int Standards.UUID.UUID.var
The variant of the UUID.
string str_variant()
Returns a string representation of the variant, e.g.
"IETF draft variant".
int Standards.UUID.UUID.clk_seq
The clock sequence. Should be 13 to 15 bits depending on UUID version.
int Standards.UUID.UUID.node
The UUID node. Should be 48 bit.
void validate()
Validates the current UUID.
int time_low()
Returns the time_low field.
int time_mid()
Returns the time_mid field.
int time_hi_and_version()
Returns the time_hi_and_version field.
string encode()
Encodes a binary representation of the UUID.
string str()
Creates a string representation of the UUID.
string urn()
Creates a URN representation of the UUID.
void Standards.UUID.UUID(void|string in)
Optionally created with a string or binary representation of a UUID.
| Module Standards.ID3 |
ID3 decoder/encoder. Supports versions 1.0, 1.1, 2.2-2.4. For more info see http://www.id3.org
Note that this implementation is far from complete and that interface changes might be neccessary during the implementation of the full standard.
int synchsafe_to_int(array(int) bytes)
Decodes a synchsafe integer, generated according to ID3v2.4.0-structure section 6.2.
int_to_synchsafe
array(int) int_to_synchsafe(int in, void|int no_bytes)
Encodes a integer to a synchsafe integer according to ID3v2.4.0-structure section 6.2.
synchsafe_to_int
string resynchronise(string in)
Reverses the effects of unsyncronisation done according to ID3v2.4.0-structure section 6.1.
unsynchronise
string unsynchronise(string in)
Unsynchronises the string according to ID3v2.4.0-structure section 6.1.
resynchronise
string decode_string(string in, int type)
Decodes the string in from the type , according to ID3v2.4.0-structure section 4, into a wide string.
encode_string
array(string|int) encode_string(string in)
Encodes the string in to an int-string pair, where the integer is the encoding mode, according to ID3v2.4.0-structure, and the string is the encoded string. This function tries to minimize the size of the encoded string by selecting the most apropriate encoding method.
decode_string , encode_strings
array(string|int) encode_strings(array(string) in)
Encodes several strings in the same way as encode_string , but encodes all the strings with the same method, selected as in encode_string . The first element in the resulting array is the selected method, while the following elements are the encoded strings.
decode_string , encode_string
| CLASS Standards.ID3.Buffer |
A wrapper around a Stdio.File object that provides a read limit capability.
Stdio.File Standards.ID3.Buffer.buffervoid Standards.ID3.Buffer(Stdio.File buffer)
string read(int bytes)
Read bytes bytes from the buffer. Throw an exception if bytes is bigger than the number of bytes left in the buffer before reaching the limit set by set_limit .
string peek()
Preview the next byte. Technically it is read from the encapsulated buffer and put locally to avoid seeking.
void set_limit(int bytes)
Set an artificial EOF bytes bytes further into the buffer.
int bytes_left()
The number of bytes left before reaching the limit set by set_limit .
| CLASS Standards.ID3.TagHeader |
Represents an ID3v2 header.
void Standards.ID3.TagHeader(void|Buffer buffer)
void decode(Buffer buffer)
Decode a tag header from buffer and store its data in this object.
string encode()
Encode the data in this tag and return as a string.
int(0..1) set_flag_unsynchronisation(array(Frame) frames)
Should the unsynchronisation flag be set or not?
| CLASS Standards.ID3.ExtendedHeader |
void Standards.ID3.ExtendedHeader(void|Buffer buffer)
void decode(Buffer buffer)
string encode()
| CLASS Standards.ID3.FrameData |
Abstract class for frame data.
void Standards.ID3.FrameData(void|string data)
int(0..1) changed()
Is the content altered?
| CLASS Standards.ID3.Frame |
Manages the common frame information.
void Standards.ID3.Frame(string|Buffer in, TagHeader thd)
| CLASS Standards.ID3.Tagv2 |
ID3 version 2 (2.2, 2.3, 2.4) Tags
void Standards.ID3.Tagv2(void|Buffer|Stdio.File buffer, void|int(0..1) _best_effort)
| CLASS Standards.ID3.Tagv1 |
ID3 version 1.0 or 1.1 tag. This is really a clumsy way of reading ID3v1 tags, but it has the same interface as the v2 reader.
| CLASS Standards.ID3.Tag |
This is a ID3 tag super object, which encapsulates all versions ID3 tags. This is useful if you are only interested in the metadata of a file, and care not about how it is stored or have no interest in changing the data.
Version 1 tag is searched only if version 2 isn't found.
Tagv2 , Tagv1
void Standards.ID3.Tag(Stdio.File fd)
The file object fd is searched for version 2 tags, and if not found, version 1 tags.
If no tag was found in the file an error is thrown.
mixed `[](string index)
mixed `->(string index)
The index operators are overloaded to index the encapsulated Tagv1 or Tagv2 object.
constant Standards.ID3.Tag.version
The version of the encapsulated tag in the form "%d.%d.%d".
array _indices()
Indices will return the indices of the tag object.
array _values()
Values will return the values of the tag object.
mapping(string:string) friendly_values()
Returns tag values in a mapping. Only tag values that exists in ID3v1.1 is used. Nonexisting or undefined values will not appear in the mapping.
|
| Module Standards.IDNA |
This module implements various algorithms specified by the Internationalizing Domain Names in Applications (IDNA) memo by the Internet Engineering Task Force (IETF), see ftp://ftp.rfc-editor.org/in-notes/rfc3490.txt.
object Standards.IDNA.Punycode
Punycode transcoder, see ftp://ftp.rfc-editor.org/in-notes/rfc3492.txt. Punycode is used by to_ascii as an "ASCII Compatible Encoding" when needed.
string nameprep(string s, int(0..1)|void allow_unassigned)
Prepare a Unicode string for ACE transcoding. Used by to_ascii . Nameprep is a profile of Stringprep, which is described in RFC 3454.
The string to prep.
Set this flag the the string to transform is a "query string", and not a "stored string". See RFC 3454.
string to_ascii(string s, int(0..1)|void allow_unassigned, int(0..1)|void use_std3_ascii_rules)
The to_ascii operation takes a sequence of Unicode code points that make up one label and transforms it into a sequence of code points in the ASCII range (0..7F). If to_ascci succeeds, the original sequence and the resulting sequence are equivalent labels.
The sequence of Unicode code points to transform.
Set this flag if the the string to transform is a "query string", and not a "stored string". See RFC 3454.
Set this flag to enforce the restrictions on ASCII characters in host names imposed by STD3.
string to_unicode(string s)
The to_unicode operation takes a sequence of Unicode code points that make up one label and returns a sequence of Unicode code points. If the input sequence is a label in ACE form, then the result is an equivalent internationalized label that is not in ACE form, otherwise the original sequence is returned unaltered.
The sequence of Unicode code points to transform.
string zone_to_ascii(string s, int(0..1)|void allow_unassigned, int(0..1)|void use_std3_ascii_rules)
Takes a sequence of labels separated by '.' and applies to_ascii on each.
string zone_to_unicode(string s)
Takes a sequence of labels separated by '.' and applies to_unicode on each.
| Module Standards.TLD |
constant Standards.TLD.cc
A mapping between country TLDs and the name of the country.
multiset Standards.TLD.generic
A multiset containing the generic TLDs, such as "com" and "info".
| Module Standards.EXIF |
This module implements EXIF (Exchangeable image file format for Digital Still Cameras) 2.2 parsing.
mapping get_properties(Stdio.File file)
Retrieve the EXIF properties of the given file.
The Stdio.File object containing wanted EXIF properties.
A mapping with all found EXIF properties.
| Module Crypto |
Various cryptographic classes and functions.
Hash functions These are based on the Hash API; MD2 , MD4 , MD5 , SHA1 , SHA256 .
Stream cipher functions These are based on the Cipher API; AES , Arcfour , Blowfish , CAST , DES , DES3 , IDEA , Serpent , Twofish . The Substitution program is compatible with the CipherState. Also conforming to the API are the helper programs Buffer , CBC and Pipe .
As the cryptographic services offered from this module isn't necessarily used for security applications, none of the strings inputted or outputted are marked as secure. This is up to the caller.
This module is only available if Pike has been compiled with Nettle enabled (this is the default).
string make_crypt_md5(string password, void|string salt)
Hashes a password together with a salt with the crypt_md5 algorithm and returns the result.
verify_crypt_md5
int(0..1) verify_crypt_md5(string password, string hash)
Verifies the password against the crypt_md5 hash.
May throw an exception if the hash value is bad.
make_crypt_md5
string rot13(string data)
Convenience function that accesses the crypt function of a substitution object keyed to perform standard ROT13 (de)ciphering.
| CLASS Crypto.Hash |
Abstract class for hash algorithms. Contains some tools useful for all hashes.
inherit Nettle.HashInfo : HashInfo
HashState `()()
Calling `() will return a Nettle.HashState object.
| CLASS Crypto.Cipher |
Abstract class for crypto algorithms. Contains some tools useful for all ciphers.
inherit Nettle.CipherInfo : CipherInfo
CipherState `()()
Calling `() will return a Nettle.CipherState object.
string encrypt(string key, string data)
Works as a shortcut for obj->set_encrypt_key(key)->crypt(data)
string decrypt(string key, string data)
Works as a shortcut for obj->set_decrypt_key(key)->crypt(data)
| CLASS Crypto.Pipe |
A wrapper class that connects several cipher algorithms into one
algorithm. E.g. triple DES can be emulated with
Crypto.Pipe(Crypto.DES, Crypto.DES, Crypto.DES).
| CLASS Crypto.Substitution |
Implements a simple substitution crypto, ie. one of the first crypto systems ever invented and thus one of the least secure ones available.
this_program set_key(mapping(string:string|array(string)) key)
Sets the encryption and decryption key. The decryption key is derived from the encryption key by reversing the mapping. If one index maps to an array of strings, one element from the array will be chosen at random in such substitution.
An error is thrown if the encryption key can not be made reversible.
this_program set_null_chars(int|float p, array(string) chars)
Set null characters (fillers). Characters from chars will be inserted into the output stream with a probability p .
A float between 0.0 and 1.0 or an integer between 0 and 100.
An array of one character strings.
this_program set_rot_key(void|int steps, void|array(string) alphabet)
Sets the key to a ROT substitution system. steps defaults to 13 and alphabet defaults to A-Z, i.e. this function defaults to set the substitution crypto to be ROT13. If no alphabet is given the key will be case insensitive, e.g. the key will really be two ROT13 alphabets, one a-z and one A-Z, used simultaneously.
this_program set_ACA_K1_key(string key, void|int offset, void|array(string) alphabet)
Sets the key according to ACA K1 key generation. The plaintext alphabet is prepended with a keyword key that shifts the alphabet positions compared to the cryptogram alphabet. The plaintext alphabet is then reduced with the characters in the keyword. It is also optionally rotated offset number of steps.
this_program set_ACA_K2_key(string key, void|int offset, void|array(string) alphabet)
Sets the key according to ACA K2 key generation. The cryptogram alphabet is prepended with a keyword key that shifts the alphabet positions compared to the plaintext alphabet. The cryptogram alphabet is then reduced with the characters in the keyword. It is als optionally reotated offset number of steps.
this_program set_ACA_K3_key(string key, int offset, void|array(string) alphabet)
Sets the key according to ACA K3 key generation. Both the plaintext and the cryptogram alphabets are prepended with a keyword key , which characters are removed from the rest of the alphabet. The plaintext alphabet is then rotated offset number of steps.
this_program set_ACA_K4_key(string key1, string key2, void|int offset, void|array(string) alphabet)
Sets the key according to ACA K4 key generation. Both the plaintext and the cryptogram alphabets are prepended with the keywords key1 and key2 . The plaintext alphabet is then rotated offset number of steps.
string encrypt(string m)
Encrypts the message m .
string decrypt(string c)
Decrypts the cryptogram c .
string filter(string m, void|multiset(int) save)
Removes characters not in the encryption key or in the save multiset from the message m .
| CLASS Crypto.RSA |
Gmp.mpz get_n()
Returns the RSA modulo (n).
Gmp.mpz get_e()
Returns the RSA public exponent (e).
Gmp.mpz get_d()
Returns the RSA private exponent (d), if known.
Gmp.mpz get_p()
Returns the first RSA prime (p), if known.
Gmp.mpz get_q()
Returns the second RSA prime (q), if known.
string cooked_get_n()
Returns the RSA modulo (n) as a binary string.
string cooked_get_e()
Returns the RSA public exponent (e) as a binary string.
string cooked_get_d()
Returns the RSA private exponent (d) as a binary string, if known.
string cooked_get_p()
Returns the first RSA prime (p) as a binary string, if known.
string cooked_get_q()
Returns the second RSA prime (q) as a binary string, if known.
this_program set_public_key(Gmp.mpz|int modulo, Gmp.mpz|int pub)
Sets the public key.
The RSA modulo, often called n. This value needs to be >=12.
The public RSA exponent, often called e.
this_program set_private_key(Gmp.mpz|int priv, array(Gmp.mpz|int)|void extra)
Sets the private key.
The private RSA exponent, often called d.
| ||||||
int query_blocksize()
Returns the crypto block size, or zero if not yet set.
Gmp.mpz rsa_pad(string message, int(1..2) type, function(int:string)|void random)
Pads the message to the current block size with method type and returns the result as an integer. This is equvivalent to OS2IP(EME-PKCS1-V1_5-ENCODE(message)) in PKCS-1.
|
string rsa_unpad(Gmp.mpz block, int type)
Reverse the effect of rsa_pad .
Gmp.mpz raw_sign(string digest)
Pads the digest with rsa_pad type 1 and signs it.
string cooked_sign(string digest)
Signs digest as raw_sign and returns the signature as a byte string.
int(0..1) raw_verify(string digest, Gmp.mpz s)
Verifies the digest against the signature s , assuming pad type 1.
rsa_pad , raw_sign
string encrypt(string s, function(int:string)|void r)
Pads the message s with rsa_pad type 2, signs it and returns the signature as a byte string.
Optional random function to be passed down to rsa_pad .
string decrypt(string s)
Decrypt a message encrypted with encrypt .
int(0..) rsa_size()
Returns the size of the key in terms of number of bits.
int(0..1) public_key_equal(this_program rsa)
Compares the public key of this RSA object with another RSA object.
Gmp.mpz sign(string message, .Hash h)
Signs the message with a PKCS-1 signature using hash algorithm h .
int(0..1) verify(string msg, .Hash h, Gmp.mpz sign)
Verify PKCS-1 signature sign of message msg using hash algorithm h .
string sha_sign(string message, mixed|void r)
Document this function.
int sha_verify(string message, string signature)
Document this function.
Gmp.mpz get_prime(int bits, function(int:string) r)
Generate a prime with bits number of bits using random function r .
this_program generate_key(int(128..) bits, function(int:string)|void r)
Generate a valid RSA key pair with the size bits . A random function may be provided as arguemnt r , otherwise Crypto.Random.random_string will be used. Keys must be at least 128 bits.
this_program set_encrypt_key(array(Gmp.mpz) key)
Sets the public key to key and the mode to encryption.
set_decrypt_key , crypt
this_program set_decrypt_key(array(Gmp.mpz) key)
Sets the public key to key and the mod to decryption.
set_encrypt_key , crypt
string crypt(string s)
Encrypt or decrypt depending on set mode.
set_encrypt_key , set_decrypt_key
string name()
Returns the string "RSA".
| CLASS Crypto.DSA |
The Digital Signature Algorithm (aka DSS, Digital Signature Standard).
Gmp.mpz get_p()
Returns the modulo.
Gmp.mpz get_q()
Returns the group order.
Gmp.mpz get_g()
Returns the generator.
Gmp.mpz get_y()
Returns the public key.
Gmp.mpz get_x()
Returns the private key.
this_program set_public_key(Gmp.mpz p_, Gmp.mpz q_, Gmp.mpz g_, Gmp.mpz y_)
Sets the public key in this DSA object.
this_program set_private_key(Gmp.mpz secret)
Sets the private key in this DSA object.
this_program set_random(function(int:string) r)
Sets the random function, used to generate keys and parameters, to the function r . Default is Crypto.Random.random_string .
Gmp.mpz hash(string msg)
Makes a DSA hash of the messge msg .
array(Gmp.mpz) raw_sign(Gmp.mpz h, void|Gmp.mpz k)
Sign the message h . Returns the signature as two Gmp.mpz objects.
int(0..1) raw_verify(Gmp.mpz h, Gmp.mpz r, Gmp.mpz s)
Verify the signature r ,s against the message h .
string sign_rsaref(string msg)
Make a RSA ref signature of message msg .
int(0..1) verify_rsaref(string msg, string s)
Verify a RSA ref signature s of message msg .
string sign_ssl(string msg)
Make an SSL signatrue of message msg .
int(0..1) verify_ssl(string msg, string s)
Verify an SSL signature s of message msg .
array(Gmp.mpz) nist_primes(int l)
The (slow) NIST method of generating a DSA prime pair. Algorithm 4.56 of Handbook of Applied Cryptography.
this_program generate_parameters(int bits)
Generate key parameters using nist_primes .
this_program generate_key()
Generates a public/private key pair. Needs the public parameters p, q and g set, either through set_public_key or generate_parameters .
int(0..1) public_key_equal(.DSA dsa)
Compares the public key in this object with that in the provided DSA object.
string name()
Returns the string "DSA".
| CLASS Crypto.HMAC |
HMAC, defined by RFC-2104
void Crypto.HMAC(.Hash h, int|void b)
The hash object on which the HMAC object should base its operations. Typical input is Crypto.MD5 .
The block size of one compression block, in octets. Defaults to 64.
string raw_hash(string s)
Calls the hash function given to create and returns the hash value of s .
string pkcs_digest(string s)
Makes a PKCS-1 digestinfo block with the message s .
Standards.PKCS.Signature.build_digestinfo
| CLASS Crypto.HMAC.`() |
Calling the HMAC object with a password returns a new object that
can perform the actual HMAC hashing. E.g. doing a HMAC hash with
MD5 and the password "bar" of the string "foo"
would require the code Crypto.HMAC(Crypto.MD5)("bar")("foo").
void Crypto.HMAC.`()(string passwd)
The secret password (K).
string `()(string text)
Hashes the text according to the HMAC algorithm and returns the hash value.
string digest_info(string text)
Hashes the text according to the HMAC algorithm and returns the hash value as a PKCS-1 digestinfo block.
| CLASS Crypto.CBC |
Implementation of the cipher block chaining mode (CBC). Works as a wrapper for the cipher algorithm put in create.
void Crypto.CBC(program|object|function cipher, mixed ... args)
Initialize the CBC wrapper with a cipher algorithm. If it is a program, an object will be instantiated with args as arguments. If it is an object that doesn't conform to the cipher API, but has an LFUN::`() , that LFUN will be called. If it is a function, that function will be called with args as arguments.
string name()
Returns the string "CBC(x)" where x is the
encapsulated algorithm.
int block_size()
Reurns the block size of the encapsulated cipher.
int key_size()
Returns the key size of the encapsulated cipher.
this_program set_encrypt_key(string key)
Prepare the cipher and the wrapper for encrypting with the given key .
this_program set_decrypt_key(string key)
Prepare the cipher and the wrapper for decrypting with the given key .
this_program set_iv(string iv)
Set the initialization vector to iv .
string crypt(string data)
Encrypt/decrypt data and return the result. data must be an integral number of blocks.
| CLASS Crypto.Buffer |
Acts as a buffer so that data can be fed to a cipher in blocks that doesn't correspond to cipher block sizes.
void Crypto.Buffer(program|object|function cipher, mixed ... args)
Initialize the Proxy wrapper with a cipher algorithm. If it is a program, an object will be instantiated with args as arguments. If it is an object that doesn't conform to the cipher API, but has an LFUN::`() , that LFUN will be called. If it is a function, that function will be called with args as arguments.
string name()
Returns the string "Proxy(x)" where x is the
encapsulated algorithm.
int block_size()
Get the block size of the contained block crypto.
int key_size()
Get the key size of the contained block crypto.
this_program set_encrypt_key(string key)
Set the encryption key.
As a side-effect any buffered data will be cleared.
this_program set_decrypt_key(string key)
Set the decryption key.
As a side-effect any buffered data will be cleared.
string crypt(string data)
Encrypt some data.
Adds data to be encrypted to the buffer. If there's enough data to en/decrypt a block, that will be done, and the result returned. Any uncrypted data will be left in the buffer.
string pad()
Pad and de/encrypt any data left in the buffer.
unpad()
string unpad(string data)
De/encrypt and unpad a block of data.
This performs the reverse operation of pad() .
pad()
| Module Crypto.SHA256 |
SHA256 is another hash function specified by NIST, intended as a replacement for SHA1 , generating larger digests. It outputs hash values of 256 bits, or 32 octets.
inherit Nettle.SHA256_Info : SHA256_Info
inherit .Hash : Hash
| Module Crypto.MD5 |
MD5 is a message digest function constructed by Ronald Rivest, and is described in RFC 1321. It outputs message digests of 128 bits, or 16 octets.
inherit Nettle.MD5_Info : MD5_Info
inherit .Hash : Hash
| Module Crypto.Koremutake |
Quote from Koremutake home page http://shorl.com/koremutake:
In an attempt to temporarily solve the fact that human beings seem to be inable to remember important things (such as their names, car keys and seemingly random numbers with fourteen digits in 'em), we invented Koremutake.
It is, in plain language, a way to express any large number as a sequence of syllables. The general idea is that word-sounding pieces of information are a lot easier to remember than a sequence of digits.
string encrypt(int m)
Encode an integer as a koremutake string.
int decrypt(string c)
Decode a koremutake string into an integer.
| Module Crypto.DES |
DES is the old Data Encryption Standard, specified by NIST. It uses a block size of 64 bits (8 octets), and a key size of 56 bits. However, the key bits are distributed over 8 octets, where the least significant bit of each octet is used for parity. A common way to use DES is to generate 8 random octets in some way, then set the least significant bit of each octet to get odd parity, and initialize DES with the resulting key.
The key size of DES is so small that keys can be found by brute force, using specialized hardware or lots of ordinary work stations in parallel. One shouldn't be using plain DES at all today, if one uses DES at all one should be using DES3 or "triple DES".
DES also has some weak keys.
inherit Nettle.DES_Info : DES_Info
inherit .Cipher : Cipher
| Module Crypto.SHA1 |
SHA1 is a hash function specified by NIST (The U.S. National Institute for Standards and Technology). It outputs hash values of 160 bits, or 20 octets.
inherit Nettle.SHA1_Info : SHA1_Info
inherit .Hash : Hash
| Module Crypto.AES |
AES (American Encryption Standard) is a quite new block cipher, specified by NIST as a replacement for the older DES standard. The standard is the result of a competition between cipher designers. The winning design, also known as RIJNDAEL, was constructed by Joan Daemen and Vincent Rijnmen.
Like all the AES candidates, the winning design uses a block size of 128 bits, or 16 octets, and variable key-size, 128, 192 and 256 bits (16, 24 and 32 octets) being the allowed key sizes. It does not have any weak keys.
inherit Nettle.AES_Info : AES_Info
inherit .Cipher : Cipher
| Module Crypto.PGP |
PGP stuff. See RFC 2440.
mapping(string:string|mapping) decode(string s)
Decodes PGP data.
int verify_signature(string text, string sig, string pubkey)
Verify text against signature sig with the public key pubkey .
string encode_radix64(string data, string type, void|mapping(string:string) extra)
Encode PGP data with ASCII armour.
mapping(string:mixed) decode_radix64(string data)
Decode ASCII armour.
| Module Crypto.MD4 |
MD4 is a message digest function constructed by Ronald Rivest, and is described in RFC 1320. It outputs message digests of 128 bits, or 16 octets.
inherit Nettle.MD4_Info : MD4_Info
inherit .Hash : Hash
| Module Crypto.Arcfour |
Arcfour is a stream cipher, also known under the trade marked name
RC4, and it is one of the fastest ciphers around. A problem is
that the key setup of Arcfour is quite weak, you should never use
keys with structure, keys that are ordinary passwords, or
sequences of keys like "secret:1", "secret:2",
..... If you have keys that don't look like random bit strings,
and you want to use Arcfour, always hash the key before feeding it
to Arcfour.
inherit Nettle.ARCFOUR_Info : ARCFOUR_Info
inherit .Cipher : Cipher
| Module Crypto.MD2 |
MD2 is a message digest function constructed by Burton Kaliski, and is described in RFC 1319. It outputs message digests of 128 bits, or 16 octets.
inherit Nettle.MD2_Info : MD2_Info
inherit .Hash : Hash
| Module Crypto.DES3 |
The inadequate key size of DES has already been mentioned. One way to increase the key size is to pipe together several DES boxes with independent keys. It turns out that using two DES ciphers is not as secure as one might think, even if the key size of the combination is a respectable 112 bits.
The standard way to increase DES's key size is to use three DES boxes. The mode of operation is a little peculiar: the middle DES box is wired in the reverse direction. To encrypt a block with DES3, you encrypt it using the first 56 bits of the key, then decrypt it using the middle 56 bits of the key, and finally encrypt it again using the last 56 bits of the key. This is known as "ede" triple-DES, for "encrypt-decrypt-encrypt".
The "ede" construction provides some backward compatibility, as you get plain single DES simply by feeding the same key to all three boxes. That should help keeping down the gate count, and the price, of hardware circuits implementing both plain DES and DES3.
DES3 has a key size of 168 bits, but just like plain DES, useless parity bits are inserted, so that keys are represented as 24 octets (192 bits). As a 112 bit key is large enough to make brute force attacks impractical, some applications uses a "two-key" variant of triple-DES. In this mode, the same key bits are used for the first and the last DES box in the pipe, while the middle box is keyed independently. The two-key variant is believed to be secure, i.e. there are no known attacks significantly better than brute force.
inherit Nettle.DES3_Info : DES3_Info
inherit .Cipher : Cipher
| Module Crypto.Twofish |
Another AES finalist, this one designed by Bruce Schneier and others.
inherit Nettle.Twofish_Info : Twofish_Info
inherit .Cipher : Cipher
| Module Crypto.IDEA |
The IDEA(tm) block cipher is covered by patents held by ETH and a Swiss company called Ascom-Tech AG. The Swiss patent number is PCT/CH91/00117, the European patent number is EP 0 482 154 B1, and the U.S. patent number is US005214703. IDEA(tm) is a trademark of Ascom-Tech AG. There is no license fee required for noncommercial use.
inherit Nettle.IDEA_Info : IDEA_Info
inherit .Cipher : Cipher
| Module Crypto.Random |
This module contains stuff to that tries to give you the best possible random generation.
string random_string(int len)
Returns a string of length len with random content. The content is generated by a Yarrow random generator that is constantly updated with output from /dev/random on UNIX and CryptGenRandom on NT. The Yarrow random generator is fed at least the amount of random data from its sources as it outputs, thus doing its best to give at least good pseudo- random data on operating systems with bad /dev/random.
Gmp.mpz random(int top)
Returns a Gmp.mpz object with a random value between 0
and top . Uses random_string .
string blocking_random_string(int len)
Works as random_string , but may block in order to gather enough entropy to make a truely random output. Using this function is probably overkill for about all applications.
void add_entropy(string data, int entropy)
Inject additional entropy into the random generator.
The random string.
The number of bits in the random string that is truely random.
| Module Crypto.Serpent |
SERPENT is one of the AES finalists, designed by Ross Anderson, Eli Biham and Lars Knudsen. Thus, the interface and properties are similar to AES '. One peculiarity is that it is quite pointless to use it with anything but the maximum key size, smaller keys are just padded to larger ones.
inherit Nettle.Serpent_Info : Serpent_Info
inherit .Cipher : Cipher
| Module Crypto.CAST |
CAST-128 is a block cipher, specified in RFC 2144. It uses a 64 bit (8 octets) block size, and a variable key size of up to 128 bits.
inherit Nettle.CAST128_Info : CAST128_Info
inherit .Cipher : Cipher
| Module Crypto.Blowfish |
BLOWFISH is a block cipher designed by Bruce Schneier. It uses a block size of 64 bits (8 octets), and a variable key size, up to 448 bits. It has some weak keys.
inherit Nettle.BLOWFISH_Info : BLOWFISH_Info
inherit .Cipher : Cipher
| Module Crypto.NT |
| CLASS Crypto.NT.CryptContext |
Class representing an HCRYPTPROV handle.
void Crypto.NT.CryptContext(string name, string csp, int type, int flags)
Key container name. When flags is set to CRYPT_VERIFYCONTEXT
the name must be 0.
The name of the Crypto Service Provider to use. If set to
0 the user default CSP will be used.
string read(int size, string|void init)
Retreive some random data. Calls CryptGenRandom in the NT API.
| Module Calendar |
constant Calendar.nulltimerange = TimeRange
This represents the null time range, which, to differ from the zero time range (the zero-length time range), isn't placed in time. This is the result of for instance `& between two strict non-overlapping timeranges - no time at all.
It has a constant, is_nulltimerange, which is non-zero. `! on this timerange is true.
| CLASS Calendar.Calendar |
This is the base class of the calendars.
Calendar.TimeRanges.TimeRange now()
Give the zero-length time period of the current time.
| CLASS Calendar.TimeRange |
This is the base class (usually implemented by e.g. Calendar subclasses like Calendar.Second) for any time measurement and calendrar information. It defines all the things you can do with a time range or any time period.
A TimeRange doubles as both a fixed period in time, and an amount of time. For instance, a week plus a day moves the week-period one day ahead (unaligning it with the week period, and thereby reducing it to just 7 days), no matter when in time the actual day were.
TimeRange add(int n, void|TimeRange step)
calculates the (promoted) time period n steps away; if no step is given, the step's length is of the same length as the called time period.
It is not recommended to loop by adding the increment time period to a shorter period; this can cause faults, if the shorter time period doesn't exist in the incremented period. (Like week 53, day 31 of a month or the leap day of a year.)
Recommended use are like this:
// loop over the 5th of the next 10 months
TimeRange month=Month()+1;
TimeRange orig_day=month()->day(5);
for (int i=0; i<10; i++)
{
month++;
TimeRange day=month->place(orig_day);
...use day...
}
TimeRange beginning()
TimeRange end()
This gives back the zero-sized beginning or end of the called time period.
rule: range(t->beginning(),t->end())==t
Calendar calendar()
Simply gives back the calendar in use, for instance Calendar.ISO or Calendar.Discordian.
int(0..1) strictly_preceeds(TimeRange what)
int(0..1) preceeds(TimeRange what)
int(0..1) is_previous_to(TimeRange what)
int(0..1) overlaps(TimeRange what)
int(0..1) contains(TimeRange what)
int(0..1) equals(TimeRange what)
int(0..1) is_next_to(TimeRange what)
int(0..1) succeeds(TimeRange what)
int(0..1) strictly_succeeds(TimeRange what)
These methods exists to compare two periods of time on the timeline.
case predicates
<-- past future ->
|----A----| A strictly preceeds B,
|----B----| A preceeds B
|----A----| A strictly preceeds B, A preceeds B,
|----B----| A is previous to B, A touches B
|----A----| A preceeds B,
|----B----| A overlaps B, A touches B
|-------A-------| A preceeds B, A ends with B
|----B----| A overlaps B, A contains B, A touches B,
|-------A-------| A preceeds B, A succeeds B,
|---B---| A overlaps B, A contains B, A touches B
|----A----| A overlaps B, A touches B, A contains B
|----B----| A equals B, A starts with B, A ends with B
|-------A-------| A succeeds B, A starts with B
|----B----| A overlaps B, A contains B, A touches B
|----A----| A succeeds B,
|----B----| A overlaps B, A touches B
|----A----| A strictly succeeds B, A succeeds B
|----B----| A is next to B, A touches B
|----A----| A strictly succeeds B,
|----B----| A succeeds B
These methods only check the range of the first to the last time in the period; use of combined time periods (SuperTimeRange s) might not give you the result you want.
`&
void Calendar.TimeRange("unix", int unixtime)
void Calendar.TimeRange("unix", int unixtime, int seconds_len)
Create the timerange from unix time (as given by time(2)), with eventually the size of the time range in the same unit, seconds.
void Calendar.TimeRange("julian", int|float julian_day)
Create the timerange from a julian day, the standardized method of counting days. If the timerange is more then a day, it will at least enclose the day.
void Calendar.TimeRange(TimeRange from)
Create the timerange from another timerange.
This is useful when converting objects from one calendar to another. Note that the ruleset will be transferred to the new object, so this method can't be used to convert between timezones or languges - use set_timezone , set_language or set_ruleset to achieve this.
The size of the new object may be inexact; a Month object can't comprehend seconds, for instance.
TimeRange range(TimeRange other)
TimeRange space(TimeRange other)
TimeRange distance(TimeRange other)
Derives different time periods in between the called timerange and the parameter timerange.
>- the past the future -<
|--called--| |--other--|
>------------ range -----------<
>--space--<
>----- distance -----<
See also: add, TimeRanges.range, TimeRanges.space, TimeRanges.distance
int `/(TimeRange with)
int how_many(TimeRange with)
This calculates how many instances of the given timerange has passed during the called timerange.
For instance, to figure out your age, create the timerange of your lifespan, and divide with the instance of a Year .
TimeRange set_language(Rule.Language lang)
TimeRange set_language(string lang)
Language language()
Set or get the current language rule.
TimeRange next()
TimeRange prev()
Next and prev are compatible and convinience functions; a->next() is exactly the same as a+1; a=a->next() is a++.
int offset_to(TimeRange x)
Calculates offset to x; this compares two timeranges and gives the integer offset between the two starting points.
This is true for suitable a and b: a+a->offset_to(b)==b
By suitable means that a and b are of the same type and size. This is obviously true only if a+n has b as a possible result for any n.
TimeRange place(TimeRange this)
TimeRange place(TimeRange this, int(0..1) force)
This will place the given timerange in this timerange, for instance, day 37 in the year - Year(1934)->place(Day(1948 d37)) => Day(1934 d37).
The rules how to place things in different timeranges can be somewhat 'dwim'.
TimeRange set_ruleset(Ruleset r)
TimeRange ruleset(Ruleset r)
Set or get the current ruleset.
this may include timezone shanges, and change the time of day.
TimeRange set_size(TimeRange size)
TimeRange set_size(int n, TimeRange size)
Gives back a new (or the same, if the size matches) timerange with the new size. If n are given, the resulting size will be n amounts of the given size.
A negative size is not permitted; a zero one are.
TimeRange set_timezone(Timezone tz)
TimeRange set_timezone(string tz)
TimeZone timezone()
Set or get the current timezone (including dst) rule.
The time-of-day may very well change when you change timezone.
To get the time of day for a specified timezone, select the timezone before getting the time of day:
Year(2003)->...->set_timezone(TimeZone.CET)->...->hour(14)->...
array(TimeRange) `/(int|float n)
array(TimeRange) split(int|float n, object void|TimeRangewith)
This divides the called timerange into n pieces. The returned timerange type is not neccesarily of the same type as the called one. If the optional timerange is specified then the resulting timeranges will be multiples of that range (except for the last one).
known bugs: These are currently not defined for supertimeranges .
TimeRange subtract(TimeRange what)
This subtracts a period of time from another;
>- the past the future -<
|-------called-------|
|-------other--------|
<----> <- called->subtract(other)
|-------called-------|
|---third---|
<----> <---> <- called->subtract(third)
TimeRange `&(TimeRange with)
Gives the cut on the called time period
with another time period. The result is
zero if the two periods doesn't overlap.
>- the past the future -<
|-------called-------|
|-------other--------|
>----- cut -----<
TimeRange `*(int n)
This changes the amount of time in the time period. t*17 is the same as doing t->set_size (t,17).
TimeRange `+(int n)
TimeRange `+(TimeRange offset)
TimeRange `-(int m)
TimeRange `-(TimeRange x)
This calculates the (promoted) time period
either n step away or with a given offset.
These functions does use add to really
do the job:
t+n t->add(n) t is a time period
t-n t->add(-n) offset is a time period
t+offset t->add(1,offset) n is an integer
t-offset t->add(-1,offset)
n+t t->add(n)
n-t illegal
offset+t offset->add(1,t) | note this!
offset-t offset->add(-1,t) |
Mathematic rules:
x+(t-x) == t x is an integer or a time period
(x+t)-x == t t is a time period
(t+x)-x == t
o-(o-t) == t o is a time period
t++ == t+1
t-- == t-1
a-b does not give the distance between the start of a and b. Use the distance () function to calculate that.
The integer used to `+, `- and add are the number of steps the motion will be. It does never represent any fixed amount of time, like seconds or days.
int(0..1) `<(TimeRange compared_to)
int(0..1) `>(TimeRange compared_to)
These operators sorts roughty on the periods place in time. The major use might be to get multiset to work, besides sorting events clearly defined in time.
int(0..1) `==(TimeRange compared_to)
int(0..1) _equal(TimeRange compared_to)
These two overloads the operator `== and the result of the equal function.
a==b is considered true if the two timeranges are of the same type, have the same rules (language, timezone, etc) and are the same timerange.
equal(a,b) are considered true if a and b are the same timerange, exactly the same as the equals method.
The __hash method is also present, to make timeranges possible to use as keys in mappings.
known bugs: _equal is not currently possible to overload, due to weird bugs, so equal uses `== for now.
TimeRange `^(TimeRange with)
Gives the exclusive-or on the called time period
and another time period, ie the union without
the cut. The result is zero if the
two periods were the same.
>- the past the future -<
|-------called-------|
|-------other--------|
<----| |----> - exclusive or
TimeRange `|(TimeRange with)
Gives the union on the called time period
and another time period.
>- the past the future -<
|-------called-------|
|-------other--------|
<----------union---------->
| CLASS Calendar.SuperTimeRange |
This class handles the cases where you have a time period with holes. These can be created by the ^ or | operators on time ranges.
void Calendar.SuperTimeRange(array(TimeRange) parts)
A SuperTimeRange must have at least two parts, two time ranges. Otherwise, it's either not a time period at all or a normal time period.
| CLASS Calendar.Ruleset |
This is the container class for rules.
this_program set_timezone(string|Calendar.Rule.Timezone t)
this_program set_language(string|Calendar.Rule.Language lang)
this_program set_abbr2zone(mapping(string:string) abbr2zone)
Sets the guess-mapping for timezones. Default is the mapping:
|
YMD.parse
this_program set_rule(Calendar.Rule.Language|Calendar.Rule.Timezone rule)
this_program clone()
int(0..1) `==(this_program other)
| Module Calendar.Julian |
This is the Julian calendar, conjured up by the old Romans when their calendar were just too weird. It was used by the christians as so far as the 18th century in some parts of the world. (Especially the protestantic and orthodox parts.)
Don't confuse the julian day with the Julian calendar. The former is just a linear numbering of days, used in the Calendar module as a common unit for absolute time.
inherit Calendar.Gregorian : Gregorian
| Module Calendar.ISO |
This is the standard western calendar, which is a derivate of the Gregorian calendar, but with weeks that starts on Monday instead of Sunday.
inherit Calendar.Gregorian : Gregorian
| Module Calendar.Badi |
This is the Badi calendar, used in the Baha'i religion.
inherit Calendar.YMD : YMD
int daystart_offset()
function method int daystart_offset() Returns the offset to the start of the time range object
| Module Calendar.Discordian |
The Discordian calendar, as described on page 34 in the fourth edition of Principia Discordia.
Chaotic enough, it's quite simpler then the Gregorian calendar; weeks are 5 days, and evens up on a year. Months are 73 days.
The leap day is inserted at the 60th day of the first month (Chaos), giving the first month 74 days. The description of the calendar is a "perpetual date converter from the gregorian to the POEE calendar", so the leap years are the same as the gregorians.
The Principia calls months "seasons", but for simplicity I call them months in this calendar.
If anyone know more about how to treat the leap day - now it is inserted in the month and week where it lands, rather then being separated from month and weeks, I'm interested to know.
- Mirar, Pope of POEE.
inherit Calendar.Gregorian : Gregorian
| Module Calendar.Event |
| CLASS Calendar.Event.Event |
Event is an abstract class, defining what methods an Event need to have.
constant Calendar.Event.Event.is_event
This constant may be used to identify an event object.
Calendar.TimeRanges.TimeRange next(void|Calendar.TimeRanges.TimeRange from, void|int(0..1) including)
Calendar.TimeRanges.TimeRange previous(void|Calendar.TimeRanges.TimeRange from, void|int(0..1) including)
This calculates the next or previous occurance of the event, from the given timerange's start, including any event occuring at the start if that flag is set.
It returns zero if there is no next event.
These methods are virtual in the base class.
array(Calendar.TimeRanges.TimeRange) scan(Calendar.TimeRanges.TimeRange in)
This calculates the eventual events that is contained or overlapped by the given timerange. scan uses next , if not overloaded.
Calendar.Event.Easter()->scan(Calendar.Year(2000)) => ({ Day(Sun 23 Apr 2000) })
scan can return an array of overlapping timeranges.
This method must use in->calendar_object->type to create the returned timeranges, and must keep the ruleset.
mapping(Calendar.TimeRanges.TimeRange:Event) scan_events(Calendar.TimeRanges.TimeRange in)
Returns a mapping with time ranges mapped to events.
SuperEvent `|(Event ... with)
SuperEvent ``|(Event with)
Joins several events into one SuperEvent .
string describe()
Returns a description of the event.
| CLASS Calendar.Event.NullEvent |
A non-event.
inherit Event : Event
constant Calendar.Event.NullEvent.is_nullevent
This constant may be used to identify a NullEvent.
| CLASS Calendar.Event.Day_Event |
Day_Event is an abstract class, extending Event for events that are single days, using julian day numbers for the calculations.
inherit Event : Event
constant Calendar.Event.Day_Event.is_day_event
This constant may be used to identify Day_Event objects.
constant Calendar.Event.Day_Event.NODAY
Returned from scan_jd if the even searched for did not exist.
int scan_jd(Calendar.Calendar realm, int jd, int(-1..-1)|int(1..1) direction)
These methods has to be defined, and is what really does some work. It should return the next or previos julian day (>jd) when the event occurs, or the constant NODAY if it doesn't.
|
Calendar.TimeRanges.TimeRange next(void|Calendar.TimeRanges.TimeRange from, void|int(0..1) including)
Uses the virtual method scan_jd .
Event.next
Calendar.TimeRanges.TimeRange previous(void|Calendar.TimeRanges.TimeRange from, void|int(0..1) including)
Uses the virtual method scan_jd .
Event.previous
| CLASS Calendar.Event.Nameday |
This is created by the Namedays classes to represent an event for a name.
inherit Day_Event : Day_Event
constant Calendar.Event.Nameday.is_nameday
This constant may be used to identify Nameday objects.
| CLASS Calendar.Event.Namedays |
This contains a ruleset about namedays.
inherit Event : Event
constant Calendar.Event.Namedays.is_namedays
This constant may be used to identify Namedays .
array(string) names(Calendar.TimeRanges.TimeRange t)
Gives back an array of names that occur during the time period, in no particular order.
mapping(Calendar.TimeRanges.TimeRange:array(string)) namedays(Calendar.TimeRanges.TimeRange t)
Gives back an table of days with names that occur during the time period. Note that days without names will not appear in the returned mapping.
| CLASS Calendar.Event.SuperNamedays |
Container for merged Namedays objects.
inherit Event : Event
| CLASS Calendar.Event.Gregorian_Fixed |
A set date of year, counting leap day in February, used for the Gregorian fixed events in the events list.
Julian_Fixed
inherit Day_Event : Day_Event
constant Calendar.Event.Gregorian_Fixed.is_fixed
This constant may be used to identify Gregorian_Fixed objects.
void Calendar.Event.Gregorian_Fixed(string id, string name, int(1..31) month_day, int(1..12) month, int extra)
| CLASS Calendar.Event.Julian_Fixed |
A set date of year, counting leap day in February, used for the Gregorian fixed events in the events list.
Gregorian_Fixed
inherit Gregorian_Fixed : Gregorian_Fixed
constant Calendar.Event.Julian_Fixed.is_julian_fixed
This constant may be used to identify Julian_Fixed objects.
| CLASS Calendar.Event.Date |
This class represents the event of a given gregorian date. For instance, Event.Date(12,10)->next(Day()) finds the next 12 of October.
inherit Day_Event : Day_Event
void Calendar.Event.Date(int(1..31) month_day, int(1..12) month)
The event is created by a given month day and a month number (1=January, 12=December).
| CLASS Calendar.Event.Date_Weekday |
This class represents the event that a given gregorian date appears a given weekday. For instance, Event.Date_Weekday(12,10,5)->next(Day()) finds the next 12 of October that is a friday.
inherit Day_Event : Day_Event
void Calendar.Event.Date_Weekday(int month_day, int month, int weekday)
The event is created by a given month day, a month number (1=January, 12=December), and a weekday number (1=Monday, 7=Sunday).
The week day numbers used are the same as the day of week in the ISO calendar - the Gregorian calendar has 1=Sunday, 7=Saturday.
| CLASS Calendar.Event.Monthday_Weekday |
This class represents the event that a given gregorian day of month appears a given weekday. For instance, Event.Monthday_Weekday(13,5)->next(Day()) finds the next friday the 13th.
inherit Day_Event : Day_Event
void Calendar.Event.Monthday_Weekday(int month_day, int weekday)
The event is created by a given month day, and a weekday number (1=Monday, 7=Sunday).
The week day numbers used are the same as the day of week in the ISO calendar - the Gregorian calendar has 1=Sunday, 7=Saturday.
| CLASS Calendar.Event.Weekday |
This class represents any given weekday. For instance, Event.Weekday(5)->next(Day()) finds the next friday.
These are also available as the pre-defined events Events.monday , Events.tuesday , Events.wednesday , Events.thursday , Events.friday , Events.saturday and Events.sunday .
inherit Day_Event : Day_Event
void Calendar.Event.Weekday(int weekday, void|string id)
The event is created by a given weekday number (1=Monday, 7=Sunday).
The week day numbers used are the same as the day of week in the ISO calendar - the Gregorian calendar has 1=Sunday, 7=Saturday.
| CLASS Calendar.Event.Easter |
This class represents an easter.
inherit Day_Event : Day_Event
void Calendar.Event.Easter(void|int shift)
shift is the year to shift from old to new style easter calculation. Default is 1582.
int easter_yd(int y, int yjd, int leap)
Calculates the year day for the easter.
| CLASS Calendar.Event.Easter_Relative |
This class represents an easter relative event.
inherit Easter : Easter
void Calendar.Event.Easter_Relative(string id, string name, int offset)
| CLASS Calendar.Event.Orthodox_Easter_Relative |
This class represents an orthodox easter relative event.
inherit Easter_Relative : Easter_Relative
void Calendar.Event.Orthodox_Easter_Relative(string id, string name, int offset)
| CLASS Calendar.Event.Monthday_Weekday_Relative |
This class represents a monthday weekday relative event or n:th special weekday event, e.g. "fourth sunday before 24 dec" => md=24,mn=12,wd=7,n=-4
inherit Gregorian_Fixed : Gregorian_Fixed
void Calendar.Event.Monthday_Weekday_Relative(string id, string name, int(1..31) md, int(1..12) mn, int(1..7) _wd, int _n, void|int(0..1) _inclusive)
| CLASS Calendar.Event.SuperEvent |
This class holds any number of events, and adds the functionality of event flags.
Scanning (scan_events,next,etc) will drop flag information. Dig out what you need with holidays et al first.
inherit Event : Event
SuperEvent filter_flag(string flag)
SuperEvent holidays()
SuperEvent flagdays()
Filter out the events that has a certain flag set. Holidays (flag "h") are the days that are marked red in the calendar (non-working days), Flagdays (flag "f") are the days that the flag should be visible in (only some countries).
| CLASS Calendar.Event.TZShift_Event |
Event containing information about when a timezone is changed.
inherit Event : Event
Calendar.TimeRanges.TimeRange scan_shift(Calendar.Rule.Timezone tz, Calendar.TimeRanges.TimeRange from, int direction, int including)
Calendar.TimeRanges.TimeRange scan_history(Calendar.Rule.Timezone tz, Calendar.TimeRanges.TimeRange from, int direction, int(0..1) including)
Calendar.TimeRanges.TimeRange scan_rule(Calendar.Rule.Timezone tz, Calendar.TimeRanges.TimeRange from, int direction, int including)
| Module Calendar.Timezone |
This module contains all the predefined timezones. Index it with whatever timezone you want to use.
Example: Calendar.Calendar my_cal= Calendar.ISO->set_timezone(Calendar.Timezone["Europe/Stockholm"]);
A simpler way of selecting timezones might be to just give the string to set_timezone ; it indexes by itself:
Calendar.Calendar my_cal= Calendar.ISO->set_timezone("Europe/Stockholm");
Do not confuse this module with Ruleset.Timezone , which is the base class of a timezone object.
"CET" and some other standard abbreviations work too, but not all of them (due to more then one country using them).
Do not call set_timezone too often, but remember the result if possible. It might take some time to initialize a timezone object.
There are about 504 timezones with 127 different daylight saving rules. Most of them historic.
The timezone information comes from ftp://elsie.nci.nih.gov/pub/ and are not made up from scratch. Timezone bugs may be reported to the timezone mailing list, tz@elsie.nci.nih.gov, preferable with a cc to mirar+pike@mirar.org. /Mirar
TZnames
constant Calendar.Timezone.locale = Rule.Timezone
This contains the local timezone, found from various parts of the system, if possible.
constant Calendar.Timezone.localtime = Rule.Timezone
This is a special timezone, that uses localtime () and tzname to find out what current offset and timezone string to use.
locale uses this if there is no other way of finding a better timezone to use.
This timezone is limited by localtime and libc to the range of time_t, which is a MAXINT on most systems - 13 Dec 1901 20:45:52 to 19 Jan 2038 3:14:07, UTC.
| Module Calendar.Austrian |
Same as the ISO calendar, but with austrian as the default language.
This calendar exist only for backwards compatible purposes.
inherit Calendar.ISO : ISO
| Module Calendar.TZnames |
This module contains listnings of available timezones, in some different ways
constant Calendar.TZnames.zones = mapping(string:array(string))
This constant is a mapping that can be used to loop over to get all the region-based timezones.
It looks like this:
([ "America": ({ "Los_Angeles", "Chicago", [...] }),
"Europe": ({ "Stockholm", [...] }),
[...] }),
Please note that loading all the timezones can take some time, since they are generated and compiled on the fly.
constant Calendar.TZnames.abbr2zones = mapping(string:array(string))
This mapping is used to look up abbreviation to the possible regional zones.
It looks like this:
([ "CET": ({ "Europe/Stockholm", [...] }),
"CST": ({ "America/Chicago", "Australia/Adelaide", [...] }),
[...] }),
Note this: Just because it's noted "CST" doesn't mean it's a unique timezone. There is about 7 *different* timezones that uses "CST" as abbreviation; not at the same time, though, so the DWIM routines checks this before it's satisfied. Same with some other timezones.
For most timezones, there is a number of region timezones that for the given time are equal. This is because region timezones include rules about local summer time shifts and possible historic shifts.
The YMD.parse functions can handle timezone abbreviations by guessing.
array(string) zonenames()
This reads the zone.tab file and returns name of all standard timezones, like "Europe/Belgrade".
string _zone_tab()
array(array) zone_tab()
This returns the raw respectively parsed zone tab file from the timezone data files.
The parsed format is an array of zone tab line arrays,
({ string country_code,
string position,
string zone_name,
string comment })
To convert the position to a Geography.Position, simply feed it to the constructor.
| Module Calendar.Swedish |
Same as the ISO calendar, but with Swedish as the default language.
This calendar exist only for backwards compatible purposes.
inherit Calendar.ISO : ISO
| Module Calendar.YMD |
base for all Roman-kind of Calendars, ie, one with years, months, weeks and days
| CLASS Calendar.YMD.YMD |
Base (virtual) time period of the Roman-kind of calendar.
string format_iso_ymd()
string format_ymd()
string format_ymd_short()
string format_ymd_xshort()
string format_iso_week()
string format_iso_week_short()
string format_week()
string format_week_short()
string format_month()
string format_month_short()
string format_iso_time()
string format_time()
string format_time_short()
string format_time_xshort()
string format_mtime()
string format_xtime()
string format_tod()
string format_todz()
string format_xtod()
string format_mod()
Format the object into nice strings;
iso_ymd "2000-06-02 (Jun) -W22-5 (Fri)" [2]
ext_ymd "Friday, 2 June 2000" [2]
ymd "2000-06-02"
ymd_short "20000602"
ymd_xshort "000602" [1]
iso_week "2000-W22"
iso_week_short "2000W22"
week "2000-w22" [2]
week_short "2000w22" [2]
month "2000-06"
month_short "200006" [1]
iso_time "2000-06-02 (Jun) -W22-5 (Fri) 00:00:00 UTC+1" [2]
ext_time "Friday, 2 June 2000, 00:00:00" [2]
ctime "Fri Jun 2 00:00:00 2000\n" [2] [3]
http "Fri, 02 Jun 2000 00:00:00 GMT" [4]
time "2000-06-02 00:00:00"
time_short "20000602 00:00:00"
time_xshort "000602 00:00:00"
iso_short "2000-06-02T00:00:00"
mtime "2000-06-02 00:00"
xtime "2000-06-02 00:00:00.000000"
tod "00:00:00"
tod_short "000000"
todz "00:00:00 CET"
todz_iso "00:00:00 UTC+1"
xtod "00:00:00.000000"
mod "00:00"
[1] note conflict (think 1 February 2003)
[2] language dependent
[3] as from the libc function ctime()
[4] as specified by the HTTP standard;
not language dependent.
float fraction_no()
int hour_no()
int julian_day()
int leap_year()
int minute_no()
int month_day()
int month_no()
int second_no()
int utc_offset()
int week_day()
int week_no()
int year_day()
int year_no()
string month_name()
string month_shortname()
string month_day_name()
string week_day_name()
string week_day_shortname()
string week_name()
string year_name()
string tzname()
string tzname_iso()
function method int unix_time()
Returns the unix time integer corresponding to the start
of the time range object. (An unix time integer is UTC.)
function method datetime()
This gives back a mapping with the relevant
time information (representing the start of the period);
([ "year": int // year number (2000 AD=2000, 1 BC==0)
"month": int(1..) // month of year
"day": int(1..) // day of month
"yearday": int(0..) // day of year
"week": int(1..) // week of year
"week_day": int(0..) // day of week
"timezone": int // offset to utc, including dst
"unix": int // unix time
"julian": int // julian day
// for compatibility:
"hour": 0 // hour of day, including dst
"minute": 0 // minute of hour
"second": 0 // second of minute
"fraction": 0.0 // fraction of second
]);
Day of week is compatible with old versions, ie, 0 is sunday, 6 is saturday, so it shouldn't be used to calculate the day of the week with the given week number. Year day is also backwards compatible, ie, one (1) less then from the year_day() function.
If this function is called in a Week object that begins with the first week of a year, it returns the previous year if that is where the week starts. To keep the representation unambiguous, the returned week number is then one more than the number of weeks in that year.
E.g. Week(2008,1)->datetime() will return year 2007 and week 53 since the first week of 2008 starts in 2007.
Second second()
Second second(int n)
Minute minute(int hour, int minute, int second)
array(Second) seconds()
array(Second) seconds(int first, int last)
int number_of_seconds()
Minute minute()
Minute minute(int n)
Minute minute(int hour, int minute)
array(Minute) minutes()
array(Minute) minutes(int first, int last)
int number_of_minutes()
Hour hour()
Hour hour(int n)
array(Hour) hours()
array(Hour) hours(int first, int last)
int number_of_hours()
| CLASS Calendar.YMD.Year |
This is the time period of a year.
void Calendar.YMD.Year("unix", int unix_time)
void Calendar.YMD.Year("julian", int|float julian_day)
void Calendar.YMD.Year(int year)
void Calendar.YMD.Year(string year)
void Calendar.YMD.Year(TimeRange range)
It's possible to create the standard year by using three different methods; either the normal way - from standard unix time or the julian day, and also, for more practical use, from the year number.
Month month()
Month month(int n)
Month month(string name)
The Year type overloads the month() method, so it is possible to get a specified month by string:
year->month("April")
The integer and no argument behavior is inherited from YMD ().
Week week()
Week week(int n)
Week week(string name)
The Year type overloads the week() method, so it is possible to get a specified week by name:
year->week("17") year->week("w17")
The integer and no argument behavior is inherited from YMD ().
This is useful, since the first week of a year not always (about half the years, in the ISO calendar) is numbered '1'.
| CLASS Calendar.YMD.Week |
The Calendar week represents a standard time period of a week. In the Gregorian calendar, the standard week starts on a sunday and ends on a saturday; in the ISO calendar, it starts on a monday and ends on a sunday.
The week are might not be aligned to the year, and thus the week may cross year borders and the year of the week might not be the same as the year of all the days in the week. The basic rule is that the week year is the year that has the most days in the week, but since week number only is specified in the ISO calendar - and derivates - the week number of most calendars is the week number of most of the days in the ISO calendar, which modifies this rule for the Gregorian calendar; the week number and year is the same as for the ISO calendar, except for the sundays.
When adding, moving and subtracting months to a week, it falls back to using days.
When adding, moving or subtracting years, if tries to place the moved week in the resulting year.
void Calendar.YMD.Week("unix", int unix_time)
void Calendar.YMD.Week("julian", int|float julian_day)
void Calendar.YMD.Week(int year, int week)
It's possible to create the standard week by using three different methods; either the normal way - from standard unix time or the julian day, and also, for more practical use, from year and week number.
Can be less than 1 for the first week of the year if it begins in the previous year.
void Calendar.YMD.Week("unix", int unix_time)
void Calendar.YMD.Week("julian", int|float julian_day)
void Calendar.YMD.Week(int year, int month, int day)
void Calendar.YMD.Week(int year, int year_day)
void Calendar.YMD.Week(int julian_day)
It's possible to create the day by using five different methods; either the normal way - from standard unix time or the julian day, and also, for more practical use, from year, month and day, from year and day of year, and from julian day without extra fuzz.
Day day()
Day day(int n)
Day day(string name)
The Week type overloads the day() method, so it is possible to get a specified weekday by string:
week->day("sunday")
The integer and no argument behavior is inherited from YMD ().
the weekday-from-string routine is language dependent.
| CLASS Calendar.YMD.Hour |
global convinience functions
TimeRange parse(string fmt, string arg)
parse a date, create relevant object
fmt is in the format "abc%xdef..."
where abc and def is matched, and %x is
one of those time units:
%Y absolute year
%y dwim year (70-99 is 1970-1999, 0-69 is 2000-2069)
%M month (number, name or short name) (needs %y)
%W week (needs %y)
%D date (needs %y, %m)
%d short date (20000304, 000304)
%a day (needs %y)
%e weekday (needs %y, %w)
%h hour (needs %d, %D or %W)
%m minute (needs %h)
%s second (needs %m)
%S seconds since the Epoch (only combines with %f)
%f fraction of a second (needs %s or %S)
%t short time (205314, 2053)
%z zone
%p "am" or "pm"
%n empty string (to be put at the end of formats)
0 if format doesn't match data, or the appropriate time object.
The zone will be a guess if it doesn't state an exact regional timezone (like "Europe/Stockholm") - most zone abbriviations (like "CET") are used by more then one region with it's own daylight saving rules. Also beware that for instance CST can be up to four different zones, central Australia or America being the most common.
Abbreviation Interpretation
AMT America/Manaus [UTC-4]
AST America/Curacao [UTC-4]
CDT America/Costa_Rica [UTC-6]
CST America/El Salvador [UTC-6]
EST America/Panama [UTC-5]
GST Asia/Dubai [UTC+4]
IST Asia/Jerusalem [UTC+2]
WST Australia/Perth [UTC+8]
This mapping is modifiable in the ruleset, see
Ruleset.set_abbr2zone .
function Day dwim_day(string date)
function Day dwim_day(string date,TimeRange context)
Tries a number of different formats on the given date (in order):
parse format as in
"%y-%M-%D (%M) -W%W-%e (%e)" "2000-03-20 (Mar) -W12-1 (Mon)"
"%y-%M-%D" "2000-03-20", "00-03-20"
"%M%/%D/%y" "3/20/2000"
"%D%*[ /]%M%*[ /-,]%y" "20/3/2000" "20 mar 2000" "20/3 -00"
"%e%*[ ]%D%*[ /]%M%*[ /-,]%y" "Mon 20 Mar 2000" "Mon 20/3 2000"
"-%y%*[ /]%D%*[ /]%M" "-00 20/3" "-00 20 mar"
"-%y%*[ /]%M%*[ /]%D" "-00 3/20" "-00 march 20"
"%y%*[ /]%D%*[ /]%M" "00 20 mar" "2000 20/3"
"%y%*[ /]%M%*[ /]%D" "2000 march 20"
"%D%.%M.%y" "20.3.2000"
"%D%*[ -/]%M" "20/3" "20 mar" "20-03"
"%M%*[ -/]%D" "3/20" "march 20"
"%M-%D-%y" "03-20-2000"
"%D-%M-%y" "20-03-2000"
"%e%*[- /]%D%*[- /]%M" "mon 20 march"
"%e%*[- /]%M%*[- /]%D" "mon/march/20"
"%e%*[ -/wv]%W%*[ -/]%y" "mon w12 -00" "1 w12 2000"
"%e%*[ -/wv]%W" "mon w12"
"%d" "20000320", "000320"
"today" "today"
"last %e" "last monday"
"next %e" "next monday"
Casts exception if it fails to dwim out a day. "dwim" means do-what-i-mean.
function datetime(int|void unix_time)
Replacement for localtime; gives back a mapping:
([ "year": int // year number (2000 AD=2000, 1 BC==0)
"month": int(1..) // month of year
"day": int(1..) // day of month
"yearday": int(1..) // day of year
"week": int(1..) // week of year
"week_day": int(1..) // day of week (depending on calendar)
"unix": int // unix time
"julian": float // julian day
"hour": int(0..) // hour of day, including dst
"minute": int(0..59) // minute of hour
"second": int(0..59) // second of minute
"fraction": float // fraction of second
"timezone": int // offset to utc, including dst
]);
This is the same as calling Second ()->datetime ().
function datetime_name(int|void unix_time) function datetime_short_name(int|void unix_time) Compat functions; same as format_iso and format_iso_short .
function string format_iso(void|int unix_time)
function string format_iso_short(void|int unix_time)
function string format_iso_tod(void|int unix_time)
function string format_day_iso(void|int unix_time)
function string format_day_iso_short(void|int unix_time)
Format the object into nice strings;
iso "2000-06-02 (Jun) -W22-5 (Fri) 11:57:18 CEST"
iso_short "2000-06-02 11:57:18"
iso_tod "11:57:18"
| Module Calendar.Islamic |
This is the islamic calendar. Due to some sources, they decide the first day of the new months on a month-to-month basis (sightings of the new moon), so it's probably not that accurate. If someone can confirm (or deny) accuracy better than that, please contact me so I can change this statement.
It's vaugely based on rules presented in algorithms by Dershowitz, Reingold and Clamen, 'Calendrical Calculations'. It is the same that's used in Emacs calendar mode.
I have currently no idea how the arabic countries count the week. Follow the same rules as ISO for now... The time is also suspicious; the day really starts at sunset and not midnight, the hours of the day is not correct. Also don't know what to call years before 1 - go for "BH"; positive years are "AH", anno Hegirac.
inherit Calendar.YMD : YMD
| Module Calendar.Gregorian |
This is the standard conservative christian calendar, used regularly in some countries - USA, for instance - and which derivate - the ISO calendar - is used in most of Europe.
inherit Calendar.YMD : YMD
| Module Calendar.Rule |
| CLASS Calendar.Rule.Timezone |
Contains a time zone.
void Calendar.Rule.Timezone(int offset, string name)
Offset to UTC, not counting DST.
The name of the time zone.
array tz_ux(int unixtime)
This method takes one integer argument, ignores it and returns an array with the UTC offset and the timezone name.
array tz_jd(int julian_day)
This method takes one integer argument, ignores it and returns an array with the UTC offset and the timezone name.
int raw_utc_offset()
Returns the offset to UTC, not counting DST.
| Module Calendar.Coptic |
This is the Coptic Orthodox Church calendar, that starts the 11th or 12th September and has 13 months.
The (default) names of the months are different then other the emacs calendar; I do not know which ones are used - the difference seem to be only the transcription of the phonetic sounds (B <-> P, etc).
I do not know for how long back the calendar is valid, either. My sources claim that the calendar is synchronized with the Gregorian calendar, which is odd.
inherit Calendar.Gregorian : Gregorian
| Module Calendar.Time |
Base for time of day in calendars, ie calendars with hours, minutes, seconds
This module can't be used by itself, but is inherited by other modules (ISO by YMD , for instance).
| CLASS Calendar.Time.TimeofDay |
Virtual class used by e.g. Hour.
void call_out(function fun, mixed ...args)
Creates a call_out to this point in time.
void Calendar.Time.TimeofDay()
void Calendar.Time.TimeofDay(int unixtime)
In addition to the wide range of construction arguments for a normal TimeRange (see TimeRange.create ), a time of day can also be constructed with unixtime as single argument consisting of the unix time - as returned from time(2) - of the time unit start.
It can also be constructed without argument, which then means "now", as in "this minute".
string format_iso_ymd()
string format_ymd()
string format_ymd_short()
string format_ymd_xshort()
string format_iso_week()
string format_iso_week_short()
string format_week()
string format_week_short()
string format_month()
string format_month_short()
string format_iso_time()
string format_time()
string format_time_short()
string format_iso_short()
string format_time_xshort()
string format_mtime()
string format_xtime()
string format_tod()
string format_xtod()
string format_mod()
string format_nice()
string format_nicez()
Format the object into nice strings;
iso_ymd "2000-06-02 (Jun) -W22-5 (Fri)" [2]
ext_ymd "Friday, 2 June 2000" [2]
ymd "2000-06-02"
ymd_short "20000602"
ymd_xshort "000602" [1]
iso_week "2000-W22"
iso_week_short "2000W22"
week "2000-w22" [2]
week_short "2000w22" [2]
month "2000-06"
month_short "200006" [1]
iso_time "2000-06-02 (Jun) -W22-5 (Fri) 20:53:14 UTC+1" [2]
ext_time "Friday, 2 June 2000, 20:53:14" [2]
ctime "Fri Jun 4 20:53:14 2000\n" [2] [3]
http "Fri, 02 Jun 2000 19:53:14 GMT" [4]
time "2000-06-02 20:53:14"
time_short "20000602 20:53:14"
time_xshort "000602 20:53:14"
iso_short "20000602T20:53:14"
mtime "2000-06-02 20:53"
xtime "2000-06-02 20:53:14.000000"
todz "20:53:14 CET"
todz_iso "20:53:14 UTC+1"
tod "20:53:14"
tod_short "205314"
xtod "20:53:14.000000"
mod "20:53"
nice "2 Jun 20:53", "2 Jun 2000 20:53:14" [2][5]
nicez "2 Jun 20:53 CET" [2][5]
smtp "Fri, 2 Jun 2000 20:53:14 +0100" [6]
commonlog "02/Jun/2000:20:53:14 +0100" [2]
[1] note conflict (think 1 February 2003)
[2] language dependent
[3] as from the libc function ctime()
[4] as specified by the HTTP standard;
this is always in GMT, ie, UTC. The timezone calculations
needed will be executed implicitly. It is not language
dependent.
[5] adaptive to type and with special cases
for yesterday, tomorrow and other years
[6] as seen in Date: headers in mails
int hour_no()
int minute_no()
int second_no()
float fraction_no()
This gives back the number of the time unit,
on this day. Fraction is a float number, 0<=fraction<1.
function mapping datetime()
This gives back a mapping with the relevant
time information (representing the start of the period);
([ "year": int // year number (2000 AD=2000, 1 BC==0)
"month": int(1..) // month of year
"day": int(1..) // day of month
"yearday": int(1..) // day of year
"week": int(1..) // week of year
"week_day": int(1..) // day of week (depending on calendar)
"hour": int(0..) // hour of day, including dst
"minute": int(0..59) // minute of hour
"second": int(0..59) // second of minute
"fraction": float // fraction of second
"timezone": int // offset to utc, including dst
"unix": int // unix time
"julian": float // julian day
]);
Hour hour()
Hour hour(int n)
array(Hour) hours()
array(Hour) hours(int first, int last)
int number_of_hours()
hour () gives back the timerange representing the first or nth Hour of the called object. Note that hours normally starts to count at zero, so ->hour(2) gives the third hour within the range.
An Hour is in the Calendar perspective as any other time range not only 60 minutes, but also one of the (normally) 24 hours of the day, precisely.
hours () give back an array of all the hours containing the time periods called. With arguments, it will give back a range of those hours, in the same enumeration as the n to hour ().
number_of_hours () simple counts the number of hours containing the called time period.
Note: The called object doesn't have to *fill* all the hours it will send back, it's enough if it exist in those hours:
> object h=Calendar.Time.Hour();
Result: Hour(265567)
> h->hours();
Result: ({ /* 1 element */
Hour(265567)
})
> h+=Calendar.Time.Minute();
Result: Minute(265567:01+60m)
> h->hours();
Result: ({ /* 2 elements */
Hour(265567),
Hour(265568)
})
float julian_day()
This calculates the corresponding julian day, from the time range. Note that the calculated day is the beginning of the period, and is a float - julian day standard says .00 is midday, 12:00 pm.
Normal pike (ie, 32 bit) floats (without --with-double-precision) has a limit of about 7 digits, and since we are about julian day 2500000, the precision on time of day is very limited.
Minute minute()
Minute minute(int n)
array(Minute) minutes()
array(Minute) minutes(int first, int last)
int number_of_minutes()
minute () gives back the timerange representing the first or nth Minute of the called object. Note that minutes normally starts to count at zero, so ->minute(2) gives the third minute within the range.
An Minute is in the Calendar perspective as any other time range not only 60 seconds, but also one of the (normally) 60 minutes of the Hour , precisely.
minutes () give back an array of all the minutes containing the time periods called. With arguments, it will give back a range of those minutes, in the same enumeration as the n to minute ().
number_of_minutes () simple counts the number of minutes containing the called time period.
TimeRange move_seconds(int seconds)
TimeRange move_ns(int nanoseconds)
These two methods gives back the time range called moved the specified amount of time, with the length intact.
The motion is relative to the original position in time; 10 seconds ahead of 10:42:32 is 10:42:42, etc.
Second second()
Second second(int n)
array(Second) seconds()
array(Second) seconds(int first, int last)
int number_of_seconds()
second () gives back the timerange representing the first or nth Second of the called object. Note that seconds normally starts to count at zero, so ->second(2) gives the third second within the range.
seconds () give back an array of all the seconds containing the time periods called. With arguments, it will give back a range of those seconds, in the same enumeration as the n to second ().
number_of_seconds () simple counts the number of seconds containing the called time period.
TimeRange set_size_seconds(int seconds)
TimeRange set_size_ns(int nanoseconds)
These two methods allows the time range to be edited by size of specific units.
int unix_time()
This calculates the corresponding unix time, - as returned from time(2) - from the time range. Note that the calculated unix time is the beginning of the period.
| CLASS Calendar.Time.SuperTimeRange |
Second second()
Second second(int n)
array(Second) seconds()
array(Second) seconds(int first, int last)
int number_of_seconds()
Minute minute()
Minute minute(int n)
array(Minute) minutes()
array(Minute) minutes(int first, int last)
int number_of_minutes()
Hour hour()
Hour hour(int n)
array(Hour) hours()
array(Hour) hours(int first, int last)
int number_of_hours()
Similar to TimeofDay , the Time::SuperTimeRange has a number of methods for digging out time parts of the range. Since a SuperTimeRange is a bit more complex - the major reason for its existance it that it contains holes, this calculation is a bit more advanced too.
If a range contains the seconds, say, 1..2 and 4..5, the third second (number 2, since we start from 0) in the range would be number 4, like this:
no means this second
0 1
1 2
2 4 <- second three is missing,
3 5 as we don't have it in the example range
number_of_seconds () will in this example therefore also report 4, not 5, even if the time from start of the range to the end of the range is 5 seconds.
| CLASS Calendar.Time.Fraction |
A Fraction is a part of a second, and/or a time period with higher resolution then a second.
It contains everything that is possible to do with a Second , and also some methods of grabbing the time period with higher resolution.
Internally, the fraction time period is measured in nanoseconds. A shorter or more precise time period then in nanoseconds is not possible within the current Fraction class.
void Calendar.Time.Fraction()
void Calendar.Time.Fraction("unix", int|float unixtime)
void Calendar.Time.Fraction("unix", int|float unixtime, int|float len)
void Calendar.Time.Fraction(int y, int m, int d, int h, int m, int s, int ns)
It is possible to create a Fraction in three ways, either "now" with no arguments or from a unix time (as from time(2)), or the convenience way from ymd-hms integers.
If created from unix time, both the start of the period and the size of the period can be given in floats, both representing seconds. Note that the default float precision in pike is rather low (same as 'float' in C, the 32 bit floating point precision, normally about 7 digits), so beware that the resolution might bite you. (Internally in a Fraction, the representation is an integer.)
If created without explicit length, the fraction will always be of zero length.
TimeofDay now()
Give the zero-length time period of the current time.
Calendar set_ruleset(Ruleset r)
Ruleset ruleset()
Set or read the ruleset for the calendar. set_ruleset returns a new calendar object, but with the new ruleset.
Calendar set_timezone(Timezone tz)
Calendar set_timezone(string|Timezone tz)
TimeZone timezone()
Set or get the current timezone (including dst) rule. set_timezone returns a new calendar object, as the called calendar but with another set of rules.
Example:
> Calendar.now();
Result: Fraction(Fri 2 Jun 2000 18:03:22.010300 CET)
> Calendar.set_timezone(Calendar.Timezone.UTC)->now();
Result: Fraction(Fri 2 Jun 2000 16:03:02.323912 UTC)
| Module Calendar.Stardate |
This implements TNG stardates.
cTick now()
Give the zero-length time period of the current time.
| CLASS Calendar.Stardate.cTick |
inherit Calendar.TimeRange : TimeRange
void Calendar.Stardate.cTick(mixed ... args)
void Calendar.Stardate.cTick(int|float date)
void Calendar.Stardate.cTick()
Apart from the standard creation methods (julian day, etc), you can create a stardate from the stardate number. The length of the period will then be zero.
You can also omit any arguments to create now.
Since the precision is limited to the float type of Pike you can get non-precise results:
> Calendar.Second(Calendar.Stardate.Day(Calendar.Year()));
Result: Second(Fri 31 Dec 1999 23:59:18 CET - Sun 31 Dec 2000 23:59:18 CET)
float tic()
This gives back the start of the stardate period, as a float.
float tics()
This gives back the number of stardate tics in the period.
int number_of_seconds()
This gives back the Gregorian/Earth/ISO number of seconds, for convinience and conversion to other calendars.
int number_of_days()
This gives back the Gregorian/Earth/ISO number of days, for convinience and conversion to other calendars.
string format_long(void|int precision)
string format_short(void|int precision)
string format_vshort(void|int precision)
Format the stardate tick nicely. Precision is the number of decimals. Defaults to 3.
|
| Module Cache |
| CLASS Cache.cache |
This module serves as a front-end to different kinds of caching systems. It uses two helper objects to actually store data, and to determine expiration policies. Mechanisms to allow for distributed caching systems will be added in time, or at least that is the plan.
mixed lookup(string key)
Looks in the cache for an element with the given key and, if available, returns it. Returns 0 if the element is not available
void alookup(string key, function(string:void) callback, int|float timeout, mixed ... args)
Asynchronously look the cache up. The callback will be given as arguments the key, the value, and then any user-supplied arguments. If the timeout (in seconds) expires before any data could be retrieved, the callback is called anyways, with 0 as value.
void store(string key, mixed value, void|int max_life, void|float preciousness, void|multiset(string) dependants)
Sets some value in the cache. Notice that the actual set operation might even not happen at all if the set data doesn't make sense. For instance, storing an object or a program in an SQL-based backend will not be done, and no error will be given about the operation not being performed.
Notice that while max_life will most likely be respected (objects will be garbage-collected at pre-determined intervals anyways), the preciousness . is to be seen as advisory only for the garbage collector If some data was stored with the same key, it gets returned. Also notice that max_life is relative and in seconds. dependants are not fully implemented yet. They are implemented after a request by Martin Stjerrholm, and their purpose is to have some weak form of referential integrity. Simply speaking, they are a list of keys which (if present) will be deleted when the stored entry is deleted (either forcibly or not). They must be handled by the storage manager.
void delete(string key, void|int(0..1) hard)
Forcibly removes some key. If the 'hard' parameter is supplied and true, deleted objects will also have their lfun::destroy method called upon removal by some backends (i.e. memory)
void start_cleanup_cycle()
void async_cleanup_cache()
void threaded_cleanup_cycle()
void Cache.cache(Cache.Storage.Base storage_mgr, Cache.Policy.Base policy_mgr, void|int cleanup_cycle_delay)
Creates a new cache object. Required are a storage manager, and an expiration policy object.
| Module Cache.Storage |
| CLASS Cache.Storage.Base |
Base class for cache storage managers.
All Cache.Storage managers must provide these methods.
int(0..0)|string first()
int(0..0)|string next()
These two functions are an iterator over the cache. There is an internal cursor, which is reset by each call to first() . Subsequent calls to next() will iterate over all the contents of the cache.
These functions are not meant to be exported to the user, but are solely for the policy managers' benefit.
void set(string key, mixed value, void|int max_life, void|float preciousness, void|multiset(string) dependants)
Data-object creation is performed here if necessary, or in get() depending on the backend.
This allows the storage managers to have their own data class implementation.
int(0..0)|Cache.Data get(string key, void|int(0..1) notouch)
Fetch some data from the cache synchronously.
Be careful, as with some storage managers it might block the calling thread for some time.
void aget(string key, function(string:void) callback, mixed ... extra_callback_args)
Fetch some data from the cache asynchronously.
callback() will get as first argument key , and as second argument 0 (cache miss) or an Cache.Data object, plus any additional argument that the user may have supplied.
mixed delete(string key, void|int(0..1) hard)
Delete the entry specified by key from the cache (if present).
If hard is 1, some backends may force a destruct() on the deleted value.
Dependants (if present) are automatically deleted.
Returns the deleted entry.
| Module Cache.Policy |
| CLASS Cache.Policy.Base |
Base class for cache expiration policies.
void expire(Cache.Storage.Base storage)
Expire callback.
This function is called to expire parts of storage .
All Storage.Policy classes must MUST implement this method.
| CLASS Cache.Policy.Timed |
An access-time-based expiration policy manager.
inherit Cache.Policy.Base : Base
| Module Debug |
string pp_memory_usage()
Returns a pretty printed version of the output from memory_usage .
mapping(string:int) count_objects()
Returns the number of objects of every kind in memory.
array(array(int|string|type(mixed))) describe_program(program p)
Debug function for showing the symbol table of a program.
Returns an array of arrays with the following information for each symbol in p :
| ||||||||||||||||
The API for this function is not fixed, and has changed since Pike 7.6. In particular it would make sense to return an array of objects instead, and more information about the symbols might be added.
mapping(string:int|float) gc_status()
Get statistics from the garbage collector.
A mapping with the following content will be returned:
|
gc() , Pike.gc_parameters()
void verify_internals()
Perform sanity checks.
This function goes through most of the internal Pike structures and generates a fatal error if one of them is found to be out of order. It is only used for debugging.
This function does a more thorough check if the Pike runtime has been compiled with RTL debug.
int debug(int(0..) level)
Set the run-time debug level.
The old debug level will be returned.
This function is only available if the Pike runtime has been compiled with RTL debug.
int optimizer_debug(int(0..) level)
Set the optimizer debug level.
The old optimizer debug level will be returned.
This function is only available if the Pike runtime has been compiled with RTL debug.
int assembler_debug(int(0..) level)
Set the assembler debug level.
The old assembler debug level will be returned.
This function is only available if the Pike runtime has been compiled with RTL debug.
int compiler_trace(int(0..) level)
Set the compiler trace level.
The old compiler trace level will be returned.
This function is only available if the Pike runtime has been compiled with RTL debug.
mapping(string:int) memory_usage()
Check memory usage.
This function is mostly intended for debugging. It delivers a mapping with information about how many arrays/mappings/strings etc. there are currently allocated and how much memory they use.
Exactly what this function returns is version dependant.
_verify_internals()
void reset_dmalloc()
Only available when compiled with dmalloc.
void dmalloc_set_name(string filename, int linenumber)
Only available when compiled with dmalloc.
void list_open_fds()
Only available when compiled with dmalloc.
void locate_references(string|array|mapping|multiset|function|object|program|type(mixed) o)
This function is mostly intended for debugging. It will search through
all data structures in Pike looking for o and print the
locations on stderr. o can be anything but int or
float.
This function only exists if the Pike runtime has been compiled with RTL debug.
mixed describe(mixed x)
Prints out a description of the thing x to standard error. The description contains various internal info associated with x .
This function only exists if the Pike runtime has been compiled with RTL debug.
void gc_set_watch(array|multiset|mapping|object|function|program|string x)
Sets a watch on the given thing, so that the gc will print a message whenever it's encountered. Intended to be used together with breakpoints to debug the garbage collector.
This function only exists if the Pike runtime has been compiled with RTL debug.
void dump_backlog()
Dumps the 1024 latest executed opcodes, along with the source code lines, to standard error. The backlog is only collected on debug level 1 or higher, set with _debug or with the -d argument on the command line.
This function only exists if the Pike runtime has been compiled with RTL debug.
| CLASS Debug.Tracer |
A class that when instatiated will turn on trace, and when it's destroyed will turn it off again.
void Debug.Tracer(int level)
Sets the level of debug trace to level .
| CLASS Debug.Subject |
This is a probe subject which you can send in somewhere to get probed (not to be confused with a probe object, which does some active probing). All calls to LFUNs will be printed to stderr. It is possible to name the subject by passing a string as the first and only argument when creating the subject object.
> object s = Debug.Subject(); create() > random(s); _random() (1) Result: 0 > abs(s); `<(0) _sprintf(79, ([ "indent":2 ])) (2) Result: Debug.Subject > abs(class { inherit Debug.Subject; int `<(mixed ... args) { return 1; } }()); create() `-() destroy() (3) Result: 0 > pow(s,2); `[]("pow") Attempt to call the NULL-value Unknown program: 0(2)
| CLASS Debug.Wrapper |
This wrapper can be placed around another object to get printouts about what is happening to it. Only a few LFUNs are currently supported.
> object x=Debug.Wrapper(Crypto.MD5()); Debug.Wrapper is proxying ___Nettle.MD5_State() > x->name(); ___Nettle.MD5_State()->name (1) Result: "md5" > !x; !___Nettle.MD5_State() (2) Result: 0
void Debug.Wrapper(object x)
int(0..1) `!()
mixed `[](mixed x, void|mixed y)
mixed `->(mixed x)
array _indices()
array _values()
int _sizeof()
string _sprintf(int c, mapping(string:mixed)|void attrs)
| Module GTKSupport |
| CLASS GTKSupport.Alert |
inherit GTK.Dialog : Dialog
GTK.Button ok()
Returns the ok Button object.
void GTKSupport.Alert(string text, string|void title)
| CLASS GTKSupport.SClist |
A Clist with scrollbars. Defines the same interface as Clist .
| CLASS GTKSupport.pDrawingArea |
A Drawing area with backing store. Basically, the only difference from a drawing area widget is that this one never loose it's contents unless you do paint over them.
It also use quite a significant amount of memory if the backing pixmap has many bitplanes, and the drawing area is large.
GTK.DrawingArea
inherit GTK.DrawingArea : DrawingArea
| Module GTKSupport.Util |
mapping load_image(string filename, array|void bgcol)
Loads and decodes an image as a GDK.Pixmap .
|
mapping decode_image(string data, mapping|array|void tocolor)
Decodes an image as a GDK.Pixmap .
|
| Module GTKSupport.MenuFactory |
void set_menubar_modify_callback(function to)
The function passed as the argument to this function will be called each time the accelerator key mapping is changed by the user with the new mapping as the argument.
This function is only used when the menubar is created, once you are done with the menubar creation, the callbacks for that menubar will be fixed.
mapping get_menubar_mapping()
Returns a (flat) mapping ([ path:GTK.MenuItem ]).
This function can only be called after the menubar is created.
array(object) PopupMenuFactory(MenuDef ... definition)
Identical to MenuFactory , but creates popup menus instead.
| ||||||
array(object) MenuFactory(MenuDef ... definition)
This is the function that actually builds the menubar.
import GTK.MenuFactory; [GTK.MenuBar bar, GTK.AcceleratorTable map] = MenuFactory( MenuDef( "File/New", new_file, 0, "A-N" ), MenuDef( "File/Open", new_file, 1, "A-O" ), MenuDef( "File/Save", save_file, 0, "A-S" ), MenuDef( "File/<separator>", 0, 0 ), MenuDef( "File/Quit", _exit, 0, "A-Q" ), );
| ||||||
| CLASS GTKSupport.MenuFactory.MenuDef |
Definition of a menu item.
void assign_shortcut(string sc)
Sets a new shortcut as the current one.
The shortcut syntax is: m[m[..]]-key, where m is one or more modifier character, and key is the desired key (NOTE: Key must be in the range 0-255 currently, this will hopefully be fixed by the GTK people in the future)
The modifiers are:
|
void GTKSupport.MenuFactory.MenuDef(string path, function|void cb, mixed|void cbarg, string|void binding, int|void right)
Path is the menupath. A submenu will be created for each
"Directory" in the path, and menuitems will be created for the
"files". There are two special cases: The "file"
"<separator>" will create a thin line. The "file"-prefix
"<check>" will make the menuitem a checkmenuitem instead
of a normal menuitem.
The second and third arguments are the callback function and the
first callback function argument. If the callback function
argument is an array, the indices of the array will be pushed as
arguments. To call the function with an array as the only
argument, make an array with the array in. The callback function
will be called like callback( arg, widget ), or if arg
is an array, callback( arg[0], arg[1], ..., widget ).
The fourth argument, shortcut, is the shortcut to bind to this menu item. The shortcut can be changed later on by calling assign_shortcut , or by the user by pressing the desired keycombination over the menu item.
The shortcut syntax is: m[m[..]]-key, where m is one or more modifier character, and key is the desired key (NOTE: Key must be in the range 0-255 currently, this will hopefully be fixed by the GTK people in the future)
The modifiers are:
|
Currently ignored.
| Module Audio |
| Module Audio.Format |
Audio data format handling
API remains marked "unstable".
| CLASS Audio.Format.ANY |
this_program read_file(string filename, int|void nocheck)
Reads data from file
read_streamed
this_program read_streamed(string filename, int|void nocheck)
Reads data from stream
Ie. for packetized data source the beggining of data is searched.
read_file
this_program read_string(string data, int|void nocheck)
Reads data from string
string get_frame()
Returns frame for current position and moves cursor forward.
The operation is destructive. Ie. current data cursor is moved over.
get_data , get_sample
mapping get_sample()
Returns sample for current position and moves cursor forward.
The operation is destructive. Ie. current data cursor is moved over.
get_frame , get_data
string get_data()
Returns data only.
The operation is destructive. Ie. current data cursor is moved over.
get_frame , get_sample
int check_format()
Check if data are correctly formated.
mapping get_map()
| CLASS Audio.Format.MP3 |
A MP3 file parser with ID3 tag support.
inherit .module.ANY : ANY
mapping|int get_frame()
Gets next frame from file
Frame is represented by the following mapping. It contains from parsed frame headers and frame data itself.
([ "bitrate": int "copyright": int(0..1), "data": frame_data, "emphasis": emphasis, "extension": "channels":0, "id":1, "layer":3, "original": int(0..1), "padding": int(0..1), "private": int(0..1), "sampling": int ])
| Module Audio.Codec |
| CLASS Audio.Codec.decoder |
Decoder object.
It needs _Ffmpeg.ffmpeg module for real work.
void Audio.Codec.decoder(string|void codecname, object|void _codec)
Creates decoder object
Some of supported codec, like _Ffmpeg.CODEC_ID_*
The low level object will be used for decoder. By default _Ffmpeg.ffmpeg object will be used.
Until additional library is implemented the second parameter _codec hasn't effect.
_Ffmpeg.ffmpeg , _Ffmpeg.CODEC_ID_MP2
this_program from_file(Audio.Format.ANY file)
Set codec type from file
It uses Audio.Format.ANY 's method get_map() to determine which codec should be used.
The object Audio.Format.ANY .
mapping|int decode(int|void partial)
Decodes audio data
Only one frame will be decoded per call.
If successfull a mapping with decoded data and byte number of used input data is returned, 0 otherwise.
mapping get_status()
Returns decoder status
| Module Remote |
| CLASS Remote.Call |
mixed `()(mixed ... args)
mixed sync(mixed ... args)
void async(mixed ... args)
int exists()
int is_async()
void set_async(int a)
void Remote.Call(string objectid, string name, object connection, object context, int async)
| CLASS Remote.Connection |
void Remote.Connection(void|int nice, void|int max_call_threads)
If set, no errors will be thrown.
int connect(string host, int port, void|int timeout)
This function is called by clients to connect to a server.
string error_message()
Returns an error message for the last error, in case connect returns zero. Returns zero if the last connect call was successful.
void start_server(object c, object cx)
This function is called by servers when they have got a connection from a client. The first argument is the connection file object, and the second argument is the context to be used.
void add_close_callback(function f, mixed ... args)
Add a function that is called when the connection is closed.
void remove_close_callback(array f)
Remove a function that is called when the connection is closed.
void close()
Closes the connection nicely, after waiting in outstanding calls in both directions.
mixed call_sync(array data)
Make a call and wait for the result
void call_async(array data)
Make a call but don't wait for the result
object get_named_object(string name)
Get a named object provided by the server.
| CLASS Remote.Context |
string id_for(mixed thing)
object object_for(string id)
object function_for(string id)
array encode(mixed val)
mixed decode(array a)
array encode_call(object|string o, string|function f, array args, int type)
function|object decode_call(array data)
int decode_existp(array data)
void add(object o, string id)
string describe(array data)
void set_server_context(object ctx, object cn)
void Remote.Context(string b, object|void cn)
| CLASS Remote.Obj |
mixed get_function(string f)
mixed `[](string f)
mixed `->(string f)
int exists()
void Remote.Obj(string id, object connection, object context)
| Module Sql |
The SQL module is a unified interface between pike and all its supported databases. The parts of this module that is usuable for all normal uses is the Sql class and the sql_result class.
string people_in_group(string group) { Sql.Sql db = Sql.Sql("mysql://localhost/testdb"); return db->query("SELECT name FROM users WHERE " "group=%s", group)->name * ","; }
| CLASS Sql.postgres_result |
Sql.postgres_result contains the result of a Postgres-query. See Sql.postgres for a description of this program's functions.
inherit Postgres.postgres_result : postgres_result
| CLASS Sql.msql |
Implements the glue needed to access the Msql-module from the generic SQL module.
inherit Msql.msql : msql
| CLASS Sql.mysqls |
Implements SQL-urls for mysqls://[user[:password]@][hostname][:port][/database]
Sets the connection to SSL-mode, and sets the default configuration
file to "/etc/my.cnf".
Ought to load a suitable default configuration file for Win32 too.
This connection method only exists if the Mysql-module has been compiled with SSL-support.
inherit Sql.mysql : mysql
| CLASS Sql.pgsqls |
Implements SQL-urls for pgsqls://[user[:password]@][hostname][:port][/database]
Sets the connection to SSL-mode.
Sql.pgsql , Sql.Sql
inherit Sql.pgsql : pgsql
| CLASS Sql.tds |
The TDS SQL-protocol.
This protocol is used by Sybase and Microsoft's SQL-servers.
Sql.Sql con = Sql.Sql("tds://user:pass@host/database");
Sql.Sql()
void tds_error(string msg, mixed ... args)
Format and report an error.
int insert_id()
Fetch the identity of the last insert (if available).
This performs the query "SELECT @@identity AS insert_id".
Returns the identity of the last insert as an integer if available.
Otherwise returns 0 (zero).
string server_info()
Return a string describing the server.
string error()
Return the last error (or possibly the last warning or informational message).
void Sql.tds(string|void server, string|void database, string|void user, string|void password)
Connect to a remote SQL server via the TDS protocol.
Server to connect to.
Database to connect to.
User to access as.
An explicit domain may be specified by preceeding the user name
with the domain name and a '\\'.
Password to access with.
Usually accessed via Sql.Sql() .
Sql.Sql()
| ENUM Sql.tds.Token |
Tokens that may occur in the answers from the server.
| ENUM Sql.tds.EnvType |
Environment types.
Used by TDS_ENV_CHANGE_TOKEN
| ENUM Sql.tds.FieldType |
Field types.
| CLASS Sql.tds.Connection |
A connection to a TDS server.
Stdio.File Sql.tds.Connection.socket
The actual TCP connection.
InPacket send_packet(Packet p, int flag, int|void last)
Send a packet to the TDS server.
May only be called when the connection is idle.
If last is true an InPacket with the result will be returned.
| CLASS Sql.tds.Connection.InPacket |
An incoming packet from the TDS server.
| CLASS Sql.tds.Connection.Packet |
An outgoing packet to the TDS server.
| CLASS Sql.tds.compile_query |
A compiled query.
void Sql.tds.compile_query(string query)
Compile a query.
big_query()
| CLASS Sql.tds.big_query |
A query result set.
int|array(string|int) fetch_row()
Fetch the next row from the result set.
Returns 0 (zero) if all rows have been returned.
Otherwise returns an array(string|int) with one
entry for each field. If the field is NULL the
entry will be 0 (zero), otherwise the entry
will contain a string representing the value.
array(mapping(string:mixed)) fetch_fields()
Fetch a description of the fields in the result.
Returns an array with a mapping for each of the fields in the result.
The mappings contain the following information:
Standard fields:
|
TDS-specific fields:
|
void Sql.tds.big_query(string|compile_query query)
Execute a query against the database.
The query to execute. This can either be a string, or a compiled query.
compile_query()
| CLASS Sql.pgsql |
This is an interface to the PostgreSQL database server. This module is independent of external libraries. Note that you do not need to have a PostgreSQL server running on your host to use this module: you can connect to the database over a TCP/IP socket.
This module replaces the functionality of the older Sql.postgres and Postgres.postgres modules.
This module supports the following features:
- PostgreSQL network protocol version 3, authentication methods currently supported are: cleartext and MD5 (recommended).
- Streaming queries which do not buffer the whole resulset in memory.
- Automatic binary transfers to and from the database for most common datatypes (amongst others: integer, text and bytea types).
- SQL-injection protection by allowing just one statement per query and ignoring anything after the first (unquoted) semicolon in the query.
- COPY support for streaming up- and download.
- Accurate error messages.
- Automatic precompilation of complex queries (session cache).
- Multiple simultaneous queries on the same database connection.
- Cancelling of long running queries by force or by timeout.
- Event driven NOTIFY.
- SSL encrypted connections (optional or forced).
Refer to the PostgreSQL documentation for further details.
Multiple simultaneous queries on the same database connection is a feature that none of the other database drivers for Pike support. So, although it's efficient, its use will make switching database drivers difficult.
Sql.Sql , Sql.postgres
void Sql.pgsql()
void Sql.pgsql(string host, void|string database, void|string user, void|string password, void|mapping(string:mixed) options)
With no arguments, this function initializes (reinitializes if a connection had been previously set up) a connection to the PostgreSQL backend. Since PostgreSQL requires a database to be selected, it will try to connect to the default database. The connection may fail however for a variety of reasons, in this case the most likely of all is because you don't have enough authority to connect to that database. So use of this particular syntax is discouraged.
The host argument can have the syntax "hostname" or
"hostname:portname". This allows to specify the TCP/IP
port to connect to. If it is 0 or "", it will try
to connect to localhost, default port.
The database argument specifies the database to connect to. If
0 or "", it will try to connect to the specified
database.
The options argument currently supports at least the following:
|
For the numerous other options please check the PostgreSQL manual.
You need to have a database selected before using the sql-object, otherwise you'll get exceptions when you try to query it. Also notice that this function can raise exceptions if the db server doesn't respond, if the database doesn't exist or is not accessible by you.
Postgres.postgres , Sql.Sql , postgres->select_db
string error()
This function returns the textual description of the last
server-related error. Returns 0 if no error has occurred
yet. It is not cleared upon reading (can be invoked multiple
times, will return the same result until a new error occurs).
During the execution of a statement, this function accumulates all non-error messages (notices, warnings, etc.). If a statement does not generate any errors, this function will return all collected messages from the last statement.
To clear the error, pass 1 as argument.
big_query
string host_info()
This function returns a string describing what host are we talking to, and how (TCP/IP or UNIX sockets).
server_info
void cancelquery()
Cancels the currently running query.
This function is PostgreSQL-specific, and thus it is not available through the generic SQL-interface.
reload
void set_charset(string charset)
Changes the connection charset.
charset is a PostgreSQL charset name.
get_charset , create
string get_charset()
Returns the PostgreSQL name for the current connection charset.
set_charset , getruntimeparameters
mapping(string:string) getruntimeparameters()
Returns the set of currently active runtimeparameters for the open session; these are initialised by the options parameter during session creation, and then processed and returned by the server.
Common values are:
|
The values can be changed during a session using SET commands to the database. For other runtimeparameters check the PostgreSQL documentation.
This function is PostgreSQL-specific, and thus it is not available through the generic SQL-interface.
mapping(string:mixed) getstatistics()
Returns a mapping with a set of statistics for the current session.
Number of warnings/notices generated by the database but not collected by the application by using error after the statements that generated them.
Number of times the driver skipped asking the database to describe the statement parameters because it was already cached.
Numer of times prepared statements were used from cache instead of reparsing in the current session.
Cache size of currently prepared statements.
Sum of the number hits on statements in the current statement cache.
Total number of prepared portals generated.
Total number of prepared statements generated.
Total number of portals opened, i.e. number of statements issued to the database.
Number of times the driver had to (briefly) wait for the database to send additional data.
Total number of bytes received from the database so far.
Total number of messages received from the database (one SQL-statement requires multiple messages to be exchanged).
Total number of bytes sent to the database so far.
Total number of packets sent to the database (one packet usually contains multiple messages).
Number of times the connection to the database has been lost.
Currently still open portals, i.e. running statements.
This function is PostgreSQL-specific, and thus it is not available through the generic SQL-interface.
int setcachedepth(void|int newdepth)
Returns the old cachedepth, sets the new cachedepth for prepared statements automatic caching.
This function is PostgreSQL-specific, and thus it is not available through the generic SQL-interface.
int settimeout(void|int newtimeout)
Returns the old timeout, sets the new timeout for long running queries.
This function is PostgreSQL-specific, and thus it is not available through the generic SQL-interface.
int setportalbuffersize(void|int newportalbuffersize)
Returns the old portalbuffersize, sets the new portalbuffersize for buffering partially concurrent queries.
This function is PostgreSQL-specific, and thus it is not available through the generic SQL-interface.
int setfetchlimit(void|int newfetchlimit)
Returns the old fetchlimit, sets the new fetchlimit to interleave queries.
This function is PostgreSQL-specific, and thus it is not available through the generic SQL-interface.
void close()
Closes the connection to the database, any running queries are terminated instantly.
This function is PostgreSQL-specific, and thus it is not available through the generic SQL-interface.
void reload()
Resets the connection to the database. Can be used for a variety of reasons, for example to detect the status of a connection.
cancelquery
void select_db(string dbname)
This function allows you to connect to a database. Due to restrictions of the Postgres frontend-backend protocol, you always have to be connected to a database, so in fact this function just allows you to connect to a different database on the same server.
This function can raise exceptions if something goes wrong (backend process not running, not enough permissions..)
create
void set_notify_callback(string condition, void|function(int:void) notify_cb, void|int selfnotify, mixed ... args)
With PostgreSQL you can LISTEN to NOTIFY events. This function allows you to detect and handle such events.
Name of the notification event we're listening to. A special case is the empty string, which matches all events, and can be used as fallback function which is called only when the specific condition is not handled. Another special case is _reconnect which gets called whenever the connection unexpectedly drops and reconnects to the database.
Function to be called on receiving a notification-event of
condition condition .
The callback function is invoked with
void notify_cb(pid,condition,extrainfo, .. args);
pid is the process id of the database session that originated
the event. condition contains the current condition.
extrainfo contains optional extra information specified by
the database.
The rest of the arguments to notify_cb are passed
verbatim from args .
The callback function must return no value.
Normally notify events generated by your own session are ignored. If you want to receive those as well, set selfnotify to one.
Extra arguments to pass to notify_cb .
This function is PostgreSQL-specific, and thus it is not available through the generic SQL-interface.
string quote(string s)
This function quotes magic characters inside strings embedded in a textual query. Quoting must not be done for parameters passed in bindings.
big_query, quotebinary, create
string quotebinary(string s)
This function quotes magic characters inside binaries (bytea) embedded in a textual query. Quoting must not be done for parameters passed in bindings.
big_query, quote
This function is PostgreSQL-specific, and thus it is not available through the generic SQL-interface.
void create_db(string db)
This function creates a new database with the given name (assuming we have enough permissions to do this).
drop_db
void drop_db(string db)
This function destroys a database and all the data it contains (assuming we have enough permissions to do so). It is not possible to delete the database you're currently connected to. You can connect to database template1 to avoid connecting to any live database.
create_db
string server_info()
This function returns a string describing the server we are
talking to. It has the form "servername/serverversion"
(like the HTTP protocol description) and is most useful in
conjunction with the generic SQL-server module.
host_info
array(string) list_dbs(void|string glob)
Lists all the databases available on the server. If glob is specified, lists only those databases matching it.
array(string) list_tables(void|string glob)
Returns an array containing the names of all the tables and views in the path in the currently selected database. If a glob is specified, it will return only those tables with matching names.
array(mapping(string:mixed)) list_fields(void|string table, void|string wild)
Returns a mapping, indexed on the column name, of mappings describing the attributes of a table of the current database. If a glob is specified, will return descriptions only of the columns matching it.
The currently defined fields are:
|
Setting wild to * will include system columns in the list.
string status_commit()
Returns the current commitstatus of the connection. Returns either one of: idle intransaction infailedtransaction
This function is PostgreSQL-specific, and thus it is not available through the generic SQL-interface.
object big_query(string q, void|mapping(string|int:mixed) bindings, void|int _alltyped)
This is the only provided interface which allows you to query the database. If you wish to use the simpler "query" function, you need to use the Sql.Sql generic SQL-object.
It returns a pgsql_result object (which conforms to the Sql.sql_result standard interface for accessing data). I recommend using query() for simpler queries (because it is easier to handle, but stores all the result in memory), and big_query() for queries you expect to return huge amounts of data (it's harder to handle, but fetches results on demand).
Bindings are supported natively straight through the network. Special bindings supported are: ":_cache", to force caching or not caching for the query at hand depending on the mappingvalue.
This function can raise exceptions.
This function does not support multiple queries in one querystring. I.e. it allows for but does not require a trailing semicolon, but it simply ignores any commands after the first semicolon. This can be viewed as a limited protection against SQL-injection attacks.
Sql.Sql , Sql.sql_result , Sql.pgsql_util.pgsql_result
object streaming_query(string q, void|mapping(string|int:mixed) bindings)
This is an alias for big_query() , since big_query() already supports streaming of multiple simultaneous queries through the same connection.
big_query , Sql.Sql , Sql.sql_result
object big_typed_query(string q, void|mapping(string|int:mixed) bindings)
This function returns an object that allows streaming and typed results.
big_query , Sql.Sql , Sql.sql_result
| CLASS Sql.Sql |
Implements those functions that need not be present in all SQL-modules.
object Sql.Sql.master_sql
Object to use for the actual SQL-queries.
int(0..1) Sql.Sql.case_convert
Convert all field names in mappings to lower_case. Only relevant to databases which only implement big_query(), and use upper/mixed-case fieldnames (eg Oracle).
|
string quote(string s)
Quote a string s so that it can safely be put in a query.
All input that is used in SQL-querys should be quoted to prevent SQL injections.
Consider this harmfull code:
string my_input = "rob' OR name!='rob";
string my_query = "DELETE FROM tblUsers WHERE name='"+my_input+"'";
my_db->query(my_query);
This type of problems can be avoided by quoting my_input. my_input would then probably read something like rob\' OR name!=\'rob
Usually this is done - not by calling quote explicitly - but through using a sprintf like syntax
string my_input = "rob' OR name!='rob";
my_db->query("DELETE FROM tblUsers WHERE name=%s",my_input);
string encode_time(int t, int|void is_utc)
Converts a system time value to an appropriately formatted time spec for the database.
Time to encode.
If nonzero then time is taken as a "full" unix time spec (where the date part is ignored), otherwise it's converted as a seconds-since-midnight value.
int decode_time(string t, int|void want_utc)
Converts a database time spec to a system time value.
Time spec to decode.
Take the date part from this system time value. If zero, a seconds-since-midnight value is returned.
string encode_date(int t)
Converts a system time value to an appropriately formatted date-only spec for the database.
Time to encode.
int decode_date(string d)
Converts a database date-only spec to a system time value.
Date spec to decode.
string encode_datetime(int t)
Converts a system time value to an appropriately formatted date and time spec for the database.
Time to encode.
int decode_datetime(string datetime)
Converts a database date and time spec to a system time value.
Date and time spec to decode.
void Sql.Sql(string host)
void Sql.Sql(string host, string db)
void Sql.Sql(string host, mapping(string:int|string) options)
void Sql.Sql(string host, string db, string user)
void Sql.Sql(string host, string db, string user, string password)
void Sql.Sql(string host, string db, string user, string password, mapping(string:int|string) options)
void Sql.Sql(object host)
void Sql.Sql(object host, string db)
Create a new generic SQL object.
|
Select this database.
User name to access the database as.
Password to access the database.
Optional mapping of options. See the SQL-database documentation for the supported options. (eg Mysql.mysql()->create() ).
In versions of Pike prior to 7.2 it was possible to leave out the dbtype, but that has been deprecated, since it never worked well.
Support for options was added in Pike 7.3.
void set_charset(string charset)
Changes the charset that the connection uses for queries and returned text strings.
The charset to use. The valid values and their meanings depends
on the database brand. However, the special value
"unicode" (if supported) selects a mode where the query
and result strings are unencoded (and possibly wide) unicode
strings.
An error is thrown if the connection doesn't support the specified charset, or doesn't support charsets being set this way at all.
See the set_charset functions for each database
connection type for further details about the effects on the
connection.
get_charset , Sql.mysql.set_charset
string get_charset()
Returns the (database dependent) name of the charset used for (at least) query strings. Returns zero if the connection doesn't support charsets this way (typically means that a call to set_charset will throw an error).
set_charset , Sql.mysql.get_charset
int|string error()
Return last error message.
void select_db(string db)
Select database to access.
string|object compile_query(string q)
Compiles the query (if possible). Otherwise returns it as is. The resulting object can be used multiple times in query() and big_query().
SQL-query to compile.
array(string|mapping(string|int:mixed)) handle_extraargs(string query, array(mixed) extraargs)
Handle sprintf-based quoted arguments
array(mapping(string:string)) query(object|string q, mixed ... extraargs)
Send an SQL query to the underlying SQL-server.
Query to send to the SQL-server. This can either be a string with the query, or a previously compiled query (see compile_query()).
This parameter, if specified, can be in two forms:
A mapping containing bindings of variables used in the query. A variable is identified by a colon (:) followed by a name or number. Each index in the mapping corresponds to one such variable, and the value for that index is substituted (quoted) into the query wherever the variable is used.
res = query("SELECT foo FROM bar WHERE gazonk=:baz",
([":baz":"value"]));
Binary values (BLOBs) may need to be placed in multisets.
Arguments as you would use in sprintf. They are automatically quoted.
res = query("select foo from bar where gazonk=%s","value");
Returns one of the following on success:
|
Throws an exception if the query fails.
big_query
int|object big_query(object|string q, mixed ... extraargs)
Send an SQL query to the underlying SQL-server. The result is
returned as an Sql.sql_result object. This allows for having some
more info about the result as well as processing the result in a
streaming fashion, although the result itself wasn't obtained
streamingly from the server. Returns 0 if the query didn't
return any result (e.g. INSERT or similar). For the other
arguments, they are the same as for the query() function.
query , streaming_query
int|object streaming_query(object|string q, mixed ... extraargs)
Send an SQL query to the underlying SQL-server. The result is
returned as a streaming Sql.sql_result object. This allows for
having results larger than the available memory, and returning
some more info about the result. Returns 0 if the query
didn't return any result (e.g. INSERT or similar). For the other
arguments, they are the same as for the query() function.
big_query
void create_db(string db)
Create a new database.
Name of database to create.
void drop_db(string db)
Drop database
Name of database to drop.
void shutdown()
Shutdown a database server.
void reload()
Reload the tables.
string server_info()
Return info about the current SQL-server.
string host_info()
Return info about the connection to the SQL-server.
array(string) list_dbs(string|void wild)
List available databases on this SQL-server.
Optional wildcard to match against.
array(string) list_tables(string|void wild)
List tables available in the current database.
Optional wildcard to match against.
array(mapping(string:mixed)) list_fields(string table, string|void wild)
List fields available in the specified table
Table to list the fields of.
Optional wildcard to match against.
| CLASS Sql.sql_result |
Implements the generic result of the SQL-interface. Used for return results from SQL.sql->big_query().
mixed Sql.sql_result.master_res
The actual result.
int Sql.sql_result.index
This is the number of the current row. The actual semantics differs between different databases.
void Sql.sql_result(mixed res)
Create a new Sql.sql_result object
Result to use as base.
int num_rows()
Returns the number of rows in the result.
int num_fields()
Returns the number of fields in the result.
int eof()
Returns non-zero if there are no more rows.
array(mapping(string:mixed)) fetch_fields()
Return information about the available fields.
void seek(int skip)
Skip past a number of rows.
Number of rows to skip.
int|array(string|int) fetch_row()
Fetch the next row from the result.
| CLASS Sql.postgres |
This is an interface to the Postgres (Postgres95, pgsql) database server. This module may or may not be available on your Pike, depending whether the appropriate include and library files could be found at compile-time. Note that you do not need to have a Postgres server running on your host to use this module: you can connect to the database over a TCP/IP socket.
Please note that there is a more advanced driver to access PostgreSQL databases: Sql.pgsql .
Also note that this module uses blocking I/O to connect to the server. It is thread-safe, and so it can be used in a multithread environment.
The behavior of the Postgres C API also depends on certain environment variables defined in the environment of the Pike interpreter; some notice and warning notifications might are dumped on stderr.
|
Refer to the Postgres documentation for further details.
Sql.pgsql , Sql.Sql , Postgres.postgres , Sql.postgres_result
inherit Postgres.postgres : mo
void select_db(string dbname)
This function allows you to connect to a database. Due to restrictions of the Postgres frontend-backend protocol, you always have to be connected to a database, so in fact this function just allows you to connect to a different database on the same server.
This function can raise exceptions if something goes wrong (backend process not running, not enough permissions..)
create
string error()
This function returns the textual description of the last
server-related error. Returns 0 if no error has occurred
yet. It is not cleared upon reading (can be invoked multiple
times, will return the same result until a new error occurs).
big_query
string host_info()
This function returns a string describing what host are we talking to, and how (TCP/IP or UNIX sockets).
void reset()
This function resets the connection to the backend. Can be used for a variety of reasons, for example to detect the status of a connection.
This function is Postgres-specific, and thus it is not available through the generic SQL-interface.
string Sql.postgres.version
Should you need to report a bug to the author, please submit along with the report the driver version number, as returned by this call.
void Sql.postgres()
void Sql.postgres(string host, void|string database, void|string user, void|string password)
With no arguments, this function initializes (reinitializes if a connection had been previously set up) a connection to the Postgres backend. Since Postgres requires a database to be selected, it will try to connect to the default database. The connection may fail however for a variety of reasons, in this case the most likely of all is because you don't have enough authority to connect to that database. So use of this particular syntax is discouraged.
The host argument can have the syntax "hostname" or
"hostname:portname". This allows to specify the TCP/IP
port to connect to. If it is 0 or "", it will try
to connect to localhost, default port.
The database argument specifies the database to connect to. If
0 or "", it will try to connect to the specified
database.
The username and password arguments are silently ignored, since the Postgres C API doesn't allow to connect to the server as any user different than the user running the interface.
You need to have a database selected before using the sql-object, otherwise you'll get exceptions when you try to query it. Also notice that this function can raise exceptions if the db server doesn't respond, if the database doesn't exist or is not accessible by you.
You don't need bothering about syncronizing the connection to the database: it is automatically closed (and the database is sync-ed) when the object is destroyed.
Sql.pgsql , Postgres.postgres , Sql.Sql , postgres->select_db
void set_notify_callback()
void set_notify_callback(function f)
void set_notify_callback(function f, int|float poll_delay)
With Postgres you can associate events and notifications to tables. This function allows you to detect and handle such events.
With no arguments, resets and removes any callback you might have put previously, and any polling cycle.
With one argument, sets the notification callback (there can be only one for each sqlobject).
With two arguments, sets a notification callback and sets a polling cycle.
The polling cycle is necessary because of the way notifications are delivered, that is piggyback with a query result. This means that if you don't do any query, you'll receive no notification. The polling cycle starts a call_out cycle which will do an empty query when the specified interval expires, so that pending notifications may be delivered.
The callback function must return no value, and takes a string argument, which will be the name of the table on which the notification event has occured. In future versions, support for user-specified arguments will be added.
The polling cycle can be run only if your process is in "event-driven mode" (that is, if 'main' has returned a negative number).
This function is Postgres-specific, and thus it is not available through the generic SQL-interface.
An integer can be passed as first argument, but it's effect is not documented.
void create_db(string db)
This function creates a new database with the given name (assuming we have enough permissions to do this).
drop_db
void drop_db(string db)
This function destroys a database and all the data it contains (assuming we have enough permissions to do so).
create_db
string server_info()
This function returns a string describing the server we are
talking to. It has the form "servername/serverversion"
(like the HTTP protocol description) and is most useful in
conjunction with the generic SQL-server module.
array(string) list_dbs(void|string glob)
Lists all the databases available on the server. If glob is specified, lists only those databases matching it.
array(string) list_tables(void|string glob)
Returns an array containing the names of all the tables in the currently selected database. If a glob is specified, it will return only those tables whose name matches it.
array(mapping(string:mixed)) list_fields(string table, void|string wild)
Returns a mapping, indexed on the column name, of mappings describing the attributes of a table of the current database. If a glob is specified, will return descriptions only of the columns matching it.
The currently defined fields are:
|
int|object big_query(object|string q, mapping(string|int:mixed)|void bindings)
This is the only provided interface which allows you to query the database. If you wish to use the simpler "query" function, you need to use the Sql.Sql generic SQL-object.
It returns a postgres_result object (which conforms to the Sql.sql_result standard interface for accessing data). I recommend using query() for simpler queries (because it is easier to handle, but stores all the result in memory), and big_query() for queries you expect to return huge amounts of data (it's harder to handle, but fetches results on demand).
This function can raise exceptions.
Sql.Sql , Sql.sql_result
int|object streaming_query(object|string q, mapping(string|int:mixed)|void bindings)
This is an alias for big_query() , since big_query() already supports streaming.
big_query , Sql.Sql , Sql.sql_result
inherit Sql.pgsql : pgsql
Maps SQL-urls for postgres://[user[:password]@][hostname][:port][/database] onto pgsql://[user[:password]@][hostname][:port][/database]
The reason this happens, is because Pike was compiled without libpq support, therefore Pike falls back to the faster, smaller memory footprint, more advanced and native PostgreSQL driver called Sql.pgsql .
Sql.pgsql , Sql.Sql
| CLASS Sql.mysql |
Implements the glue needed to access the Mysql-module from the generic SQL module.
inherit Mysql.mysql : mysql
int(0..1) set_unicode_encode_mode(int enable)
Enables or disables unicode encode mode.
In this mode, if the server supports UTF-8 and the connection
charset is latin1 (the default) or unicode then
big_query handles wide unicode queries. Enabled by default.
Unicode encode mode works as follows: Eight bit strings are sent
as latin1 and wide strings are sent using utf8.
big_query sends SET character_set_client statements as
necessary to update the charset on the server side. If the server
doesn't support that then it fails, but the wide string query
would fail anyway.
To make this transparent, string literals with introducers (e.g.
_binary 'foo') are excluded from the UTF-8 encoding. This
means that big_query needs to do some superficial parsing of
the query when it is a wide string.
|
Note that this mode doesn't affect the MySQL system variable
character_set_connection, i.e. it will still be set to
latin1 by default which means server functions like
UPPER() won't handle non-latin1 characters
correctly in all cases.
To fix that, do set_charset ("unicode"). That will
allow unicode encode mode to work while utf8 is fully
enabled at the server side.
Tip: If you enable utf8 on the server side, you need to
send raw binary strings as _binary'...'. Otherwise they
will get UTF-8 encoded by the server.
When unicode encode mode is enabled and the connection charset
is latin1, the charset accepted by big_query is not
quite Unicode since latin1 is based on cp1252.
The differences are in the range 0x80..0x9f where
Unicode has control chars.
This small discrepancy is not present when the connection
charset is unicode.
set_unicode_decode_mode , set_charset
int get_unicode_encode_mode()
Returns nonzero if unicode encode mode is enabled, zero otherwise.
set_unicode_encode_mode
void set_unicode_decode_mode(int enable)
Enable or disable unicode decode mode.
In this mode, if the server supports UTF-8 then non-binary text strings in results are automatically decoded to (possibly wide) unicode strings. Not enabled by default.
The statement "SET character_set_results = utf8" is sent
to the server to enable the mode. When the mode is disabled,
"SET character_set_results = xxx" is sent, where
xxx is the connection charset that get_charset returns.
Nonzero enables this feature, zero disables it.
Throws an exception if the server doesn't support this, i.e. if
the statement above fails. The MySQL system variable
character_set_results was added in MySQL 4.1.1.
An error is also thrown if Pike has been compiled with a MySQL client library older than 4.1.0, which lack the necessary support for this.
set_unicode_encode_mode
int get_unicode_decode_mode()
Returns nonzero if unicode decode mode is enabled, zero otherwise.
set_unicode_decode_mode
void set_charset(string charset)
Changes the connection charset. Works similar to sending the query
SET NAMES charset but also records the charset on the
client side so that various client functions work correctly.
charset is a MySQL charset name or the special value
"unicode" (see below). You can use SHOW CHARACTER
SET to get a list of valid charsets.
Specifying "unicode" as charset is the same as
"utf8" except that unicode encode and decode modes are
enabled too. Briefly, this means that you can send queries as
unencoded unicode strings and will get back non-binary text
results as unencoded unicode strings. See
set_unicode_encode_mode and set_unicode_decode_mode for
further details.
Throws an exception if the server doesn't support this, i.e. if
the statement SET NAMES fails. Support for it was added
in MySQL 4.1.0.
If charset is "latin1" and unicode encode mode is
enabled (the default) then big_query can send wide unicode
queries transparently if the server supports UTF-8. See
set_unicode_encode_mode .
If unicode decode mode is already enabled (see
set_unicode_decode_mode ) then this function won't affect the
result charset (i.e. the MySQL system variable
character_set_results).
Actually, a query SET character_set_results = utf8 will
be sent immediately after setting the charset as above if
unicode decode mode is enabled and charset isn't
"utf8".
You should always use either this function or the
"mysql_charset_name" option to create to set the
connection charset, or more specifically the charset that the
server expects queries to have (i.e. the MySQL system variable
character_set_client). Otherwise big_query might not
work correctly.
Afterwards you may change the system variable
character_set_connection, and also
character_set_results if unicode decode mode isn't
enabled.
The MySQL latin1 charset is close to Windows
cp1252. The difference from ISO-8859-1 is a bunch of
printable chars in the range 0x80..0x9f (which contains
control chars in ISO-8859-1). For instance, the euro currency
sign is 0x80.
You can use the mysql-latin1 encoding in the
Locale.Charset module to do conversions, or just use the
special "unicode" charset instead.
get_charset , set_unicode_encode_mode , set_unicode_decode_mode
string get_charset()
Returns the MySQL name for the current connection charset.
Returns "unicode" if unicode encode mode is enabled and
UTF-8 is used on the server side (i.e. in
character_set_connection).
In servers with full charset support (i.e. MySQL 4.1.0 or
later), this corresponds to the MySQL system variable
character_set_client (with one exception - see next
note) and thus controls the charset in which queries are sent.
The charset used for text strings in results might be something
else (and typically is if unicode decode mode is enabled; see
set_unicode_decode_mode ).
If the returned charset is latin1 or unicode and
unicode encode mode is enabled (the default) then
character_set_client in the server might be either
latin1 or utf8, depending on the last sent
query. See set_unicode_encode_mode for more info.
set_charset
string quote(string s)
Quote a string so that it can safely be put in a query.
String to quote.
string latin1_to_utf8(string s)
Converts a string in MySQL latin1 format to UTF-8.
string utf8_encode_query(string q, function(string:string) encode_fn)
Encodes the appropriate sections of the query with encode_fn .
Everything except strings prefixed by an introducer (i.e.
_something or N) is encoded.
string encode_time(int time, void|int date)
Converts a system time value to an appropriately formatted time spec for the database.
Time to encode.
If nonzero then time is taken as a "full" unix time spec (where the date part is ignored), otherwise it's converted as a seconds-since-midnight value.
string encode_date(int time)
Converts a system time value to an appropriately formatted date-only spec for the database.
Time to encode.
string encode_datetime(int time)
Converts a system time value to an appropriately formatted date and time spec for the database.
Time to encode.
int decode_time(string timestr, void|int date)
Converts a database time spec to a system time value.
Time spec to decode.
Take the date part from this system time value. If zero, a seconds-since-midnight value is returned.
int decode_date(string datestr)
Converts a database date-only spec to a system time value. Assumes 4-digit years.
Date spec to decode.
int decode_datetime(string timestr)
Converts a database date and time spec to a system time value. Can decode strings missing the time part.
Date and time spec to decode.
Mysql.mysql_result big_query(string query, mapping(string|int:mixed)|void bindings, void|string charset)
Sends a query to the server.
The SQL query.
An optional bindings mapping. See Sql.query for details about this.
An optional charset that will be used temporarily while sending query to the server. If necessary, a query
SET character_set_client=charset
is sent to the server first, then query is sent as-is, and then the connection charset is restored again (if necessary).
Primarily useful with charset set to "latin1" if
unicode encode mode (see set_unicode_encode_mode ) is enabled
(the default) and you have some large queries (typically blob
inserts) where you want to avoid the query parsing overhead.
A Mysql.mysql_result object is returned if the query is of a kind that returns a result. Zero is returned otherwise.
Sql.big_query
Mysql.mysql_result streaming_query(string query, mapping(string|int:mixed)|void bindings, void|string charset)
Makes a streaming SQL query.
This function sends the SQL query query to the Mysql-server. The result of the query is streamed through the returned Mysql.mysql_result object. Note that the involved database tables are locked until all the results has been read.
In all other respects, it behaves like big_query .
int(0..1) is_keyword(string name)
Return 1 if the argument name is a mysql keyword that needs to be quoted in a query. The list is currently up-to-date with MySQL 5.1.
| CLASS Sql.sqlite |
Low-level interface to SQLite3 databases.
This class should typically not be accessed directly, but instead
via Sql.Sql() with the scheme "sqlite://".
int insert_id()
Returns the value of the ROWID (aka OID, aka _ROWID_,
or declared INTEGER PRIMARY KEY) column for the most recent
successful INSERT operation, or 0 (zero) if no INSERT
operations have been performed on the connection yet.
| CLASS Sql.sqlite.ResObj |
Result object from big_query() .
| Module Sql.sql_util |
Some SQL utility functions
string quote(string s)
Quote a string so that it can safely be put in a query.
String to quote.
void fallback()
Throw an error in case an unimplemented function is called.
string emulate_bindings(string query, mapping(string|int:mixed)|void bindings, void|object driver)
Build a raw SQL query, given the cooked query and the variable bindings It's meant to be used as an emulation engine for those drivers not providing such a behaviour directly (i.e. Oracle). The raw query can contain some variables (identified by prefixing a colon to a name or a number (i.e. ":var" or ":2"). They will be replaced by the corresponding value in the mapping.
The query.
Optional mapping containing the variable bindings. Make sure that no confusion is possible in the query. If necessary, change the variables' names.
| CLASS Sql.sql_util.UnicodeWrapper |
Result object wrapper performing utf8 decoding of all fields.
protected object Sql.sql_util.UnicodeWrapper.master_resultvoid Sql.sql_util.UnicodeWrapper(object master_result)
int num_rows()
Returns the number of rows in the result.
int num_fields()
Returns the number of fields in the result.
int(0..1) eof()
Returns 1 if there are no more rows in the result.
protected array(int|mapping(string:mixed)) Sql.sql_util.UnicodeWrapper.field_info
Cached fetch_fields() result.
array(int|mapping(string:mixed)) fetch_fields()
Returns Information about the fields in the result.
The following fields are converted from UTF8 if present:
|
void seek(int rows)
Skip ahead the specified number of rows.
int|array(string) fetch_row()
Fetch the next row from the result.
All strings in the result are decoded from UTF8.
| CLASS Sql.sql_util.MySQLUnicodeWrapper |
Result wrapper for MySQL that performs UTF-8 decoding of all nonbinary fields. Useful if the result charset of the connection has been set to UTF-8.
There's normally no need to use this class directly. It's used automatically when Mysql.set_unicode_decode_mode is activated.
inherit UnicodeWrapper : UnicodeWrapper
| Module Sql.pgsql_util |
Some pgsql utility functions
| Module Calendar_I |
This module exist only for backwards compatibility issues with earlier Pike releases. Use the Calendar module instead.
This code can be used to simulate the old calendar for now (it might be removed in later Pike's):
This module has been totally rewritten in Pike 7.1+. To be forward compatible the lazy way, you can do something like this, though:
#if constant(Calendar.II)
#define Calendar Calendar_I
#endif
... import Calendar or whatever ...
This module implements calendar calculations, and base classes for time units.
| CLASS Calendar_I._TimeUnit |
Base class for units of time.
array(string) lesser()
Gives a list of methods to get lesser (shorter) time units.
ie, for a month, this gives back ({"day"})
and the method day(mixed n) gives back that
day object. The method days() gives back a
list of possible argument values to the method day.
Concurrently, Array.map(o->days(),o->day) gives
a list of day objects in the object o.
Ie:
array(string) lesser() - gives back a list of possible xxx's.
object xxxs() - gives back a list of possible n's.
object xxx(mixed n) - gives back xxx n
object xxx(object(Xxx) o) - gives back the corresponing xxx
The list of n's (as returned from xxxs) are always in order.
There are two n's with special meaning, 0 and -1.
0 always gives the first xxx, equal to
my_obj->xxx(my_obj->xxxs()[0]), and -1 gives the last,
equal to my_obj->xxx(my_obj->xxxs()[-1]).
To get all xxxs in the object, do something like
Array.map(my_obj->xxxs(),my_obj->xxx).
xxx(object) may return zero, if there was no correspondning xxx.
array(string) greater()
Gives a list of methods to get greater (longer) time units
from this object. For a month, this gives back ({"year"}),
thus the method month->year() gives the year object.
object next()
object prev()
object `+(int n)
object `-(int n)
object `-(object x)
next() and prev() give the logical next and previous object.
The `+() operator gives that logical relative object,
ie my_day+14 gives 14 days ahead.
`-() works the same way, but can also take an object
of the same type and give the difference as an integer.
| Module Calendar_I.Gregorian |
time units: Year , Month , Week , Day
object parse(string fmt, string arg)
Parse a date, create relevant object fmt is in the format "abc%xdef..." where abc and def is matched, and %x is one of those time units: %Y absolute year %y year (70-99 is 1970-1999, 0-69 is 2000-2069) %M month (number, name or short name) (needs %y) %W week (needs %y) %D date (needs %y, %m) %a day (needs %y) %e weekday (needs %y, %w) %h hour (needs %d, %D or %W) %m minute (needs %h) %s second (needs %s)
mapping(string:int) datetime(int|void unix_time, int|void skip_extra)
Replacement for localtime.
string datetime_name(int|void unix_time)
Replacement for ctime.
string datetime_short_name(int|void unix_time)
Replacement for ctime.
| CLASS Calendar_I.Gregorian.Year |
A Calendar_I.time_unit
Lesser units: Month , Week , Day Greater units: none
inherit _TimeUnit : _TimeUnit
| Module Calendar_I.Stardate |
time unit: TNGDate
| CLASS Calendar_I.Stardate.TNGDate |
Implements ST:TNG stardates. Can be used as create argument to Day.
inherit Calendar_I._TimeUnit : _TimeUnit
| Module MIME |
RFC1521, the Multipurpose Internet Mail Extensions memo, defines a structure which is the base for all messages read and written by modern mail and news programs. It is also partly the base for the HTTP protocol. Just like RFC822, MIME declares that a message should consist of two entities, the headers and the body. In addition, the following properties are given to these two entities:
A MIME-Version header must be present to signal MIME compatibility
A Content-Type header should be present to describe the nature of the data in the message body. Seven major types are defined, and an extensive number of subtypes are available. The header can also contain attributes specific to the type and subtype.
A Content-Transfer-Encoding may be present to notify that the data of the body is encoded in some particular encoding.
Raw data to be interpreted according to the Content-Type header
Can be encoded using one of several Content-Transfer-Encodings to allow transport over non 8bit clean channels
The MIME module can extract and analyze these two entities from a stream of bytes. It can also recreate such a stream from these entities. To encapsulate the headers and body entities, the class MIME.Message is used. An object of this class holds all the headers as a mapping from string to string, and it is possible to obtain the body data in either raw or encoded form as a string. Common attributes such as message type and text char set are also extracted into separate variables for easy access.
The Message class does not make any interpretation of the body data, unless the content type is multipart. A multipart message contains several individual messages separated by boundary strings. The Message->create method of the Message class will divide a multipart body on these boundaries, and then create individual Message objects for each part. These objects will be collected in the array Message->body_parts within the original Message object. If any of the new Message objects have a body of type multipart, the process is of course repeated recursively.
inherit ___MIME : ___MIME
string generate_boundary()
This function will create a string that can be used as a separator string for multipart messages. The generated string is guaranteed not to appear in base64, quoted-printable, or x-uue encoded data. It is also unlikely to appear in normal text. This function is used by the cast method of the Message class if no boundary string is specified.
string decode(string data, string encoding)
Extract raw data from an encoded string suitable for transport between systems.
The encoding can be any of
|
The encoding string is not case sensitive.
MIME.encode()
string encode(string data, string encoding, void|string filename, void|int no_linebreaks)
Encode raw data into something suitable for transport to other systems.
The encoding can be any of
|
The encoding string is not case sensitive. For the x-uue encoding, an optional filename string may be supplied.
If a nonzero value is passed as no_linebreaks , the result string will not contain any linebreaks (base64 and quoted-printable only).
MIME.decode()
array(string) decode_word(string word)
Extracts the textual content and character set from an encoded word as specified by RFC1522. The result is an array where the first element is the raw text, and the second element the name of the character set. If the input string is not an encoded word, the result is still an array, but the char set element will be set to 0.
Note that this function can only be applied to individual encoded words.
MIME.encode_word()
string encode_word(string|array(string) word, string encoding)
Create an encoded word as specified in RFC1522 from an array containing a raw text string and a char set name.
The text will be transfer encoded according to the encoding argument,
which can be either "base64" or "quoted-printable"
(or either "b" or "q" for short).
If either the second element of the array (the char set name), or the encoding argument is 0, the raw text is returned as is.
MIME.decode_word()
array(array(string)) decode_words_text(string txt)
Separates a header value containing text into units and calls MIME.decode_word() on them. The result is an array where each element is a result from decode_word() .
MIME.decode_words_tokenized MIME.decode_words_text_remapped
string decode_words_text_remapped(string txt)
Like MIME.decode_words_text() , but the extracted strings are also remapped from their specified character encoding into UNICODE, and then pasted together. The result is thus a string in the original text format, without RFC1522 escapes, and with all characters in UNICODE encoding.
MIME.decode_words_tokenized_remapped
array(array(string)|int) decode_words_tokenized(string phrase, int|void flags)
Tokenizes a header value just like MIME.tokenize() , but also
converts encoded words using MIME.decode_word() . The result is
an array where each element is either an int representing
a special character, or an array as returned by
decode_word() representing an atom or a quoted string.
MIME.decode_words_tokenized_labled MIME.decode_words_tokenized_remapped MIME.decode_words_text
array(string|int) decode_words_tokenized_remapped(string phrase, int|void flags)
Like MIME.decode_words_tokenized() , but the extracted atoms are also remapped from their specified character encoding into UNICODE. The result is thus identical to that of MIME.tokenize() , but without RFC1522 escapes, and with all characters in UNICODE encoding.
MIME.decode_words_tokenized_labled_remapped MIME.decode_words_text_remapped
array(array(string|int|array(array(string)))) decode_words_tokenized_labled(string phrase, int|void flags)
Tokenizes and labels a header value just like MIME.tokenize_labled() , but also converts encoded words using MIME.decode_word() . The result is an array where each element is an array of two or more elements, the first being the label. The rest of the array depends on the label:
|
MIME.decode_words_tokenized_labled_remapped
array(array(string|int)) decode_words_tokenized_labled_remapped(string phrase, int|void flags)
Like MIME.decode_words_tokenized_labled() , but the extracted words are also remapped from their specified character encoding into UNICODE. The result is identical to that of MIME.tokenize_labled() , but without RFC1522 escapes, and with all characters in UNICODE encoding.
string encode_words_text(array(string|array(string)) phrase, string encoding)
The inverse of decode_words_text() , this function accepts an array of strings or pairs of strings which will each be encoded by encode_word() , after which they are all pasted together.
Either "base64" or "quoted-printable"
(or either "b" or "q" for short).
MIME.encode_words_text_remapped
string encode_words_text_remapped(string text, string encoding, string|function(string:string) charset, string|void replacement, function(string:string)|void repcb)
This is the reverse of MIME.decode_words_text_remapped() . A single UNICODE string is provided, which is separated into fragments and transcoded to selected character sets by this function as needed.
Either "base64" or "quoted-printable"
(or either "b" or "q" for short).
Either the name of a character set to use, or a function returning a character set to use given a text fragment as input.
The replacement argument to use when calling Locale.Charset.encoder
The repcb argument to use when calling Locale.Charset.encoder
MIME.encode_words_tokenized_remapped
string encode_words_quoted(array(array(string)|int) phrase, string encoding)
The inverse of decode_words_tokenized() , this functions accepts an array like the argument to quote() , but instead of simple strings for atoms and quoted-strings, it will also accept pairs of strings to be passed to encode_word() .
Either "base64" or "quoted-printable"
(or either "b" or "q" for short).
MIME.encode_words_quoted_remapped() MIME.encode_words_quoted_labled()
string encode_words_quoted_remapped(array(string|int) phrase, string encoding, string|function(string:string) charset, string|void replacement, function(string:string)|void repcb)
The inverse of decode_words_tokenized_remapped() , this functions accepts an array equivalent to the argument of quote() , but also performs on demand word encoding in the same way as encode_words_text_remapped() .
MIME.encode_words_text_remapped() MIME.encode_words_quoted_labled_remapped()
string encode_words_quoted_labled(array(array(string|int|array(string|array(string)))) phrase, string encoding)
The inverse of decode_words_tokenized_labled() , this functions accepts an array like the argument to quote_labled() , but "word" labled elements can optionally contain an additional string element specifying a character set, in which case an encoded-word will be used. Also, the format for "comment" labled elements is entirely different; instead of a single string, an array of strings or pairs like the first argument to encode_words_text() is expected.
Either "base64" or "quoted-printable"
(or either "b" or "q" for short).
MIME.encode_words_quoted() MIME.encode_words_quoted_labled_remapped()
string encode_words_quoted_labled_remapped(array(array(string|int)) phrase, string encoding, string|function(string:string) charset, string|void replacement, function(string:string)|void repcb)
The inverse of decode_words_tokenized_labled_remapped() , this function accepts an array equivalent to the argument of quote_labled() , but also performs on demand word encoding in the same way as encode_words_text_remapped() .
string guess_subtype(string type)
Provide a reasonable default for the subtype field.
Some pre-RFC1521 mailers provide only a type and no subtype in the Content-Type header field. This function can be used to obtain a reasonable default subtype given the type of a message. (This is done automatically by the MIME.Message class.)
Currently, the function uses the following guesses:
|
array(mapping(string:string)|string) parse_headers(string message)
array(mapping(string:array(string))|string) parse_headers(string message, int(1..1) use_multiple)
This is a low level function that will separate the headers from the body of an encoded message. It will also translate the headers into a mapping. It will however not try to analyze the meaning of any particular header. This means that the body is returned as is, with any transfer-encoding intact.
It is possible to call this function with just the header part of a message, in which case an empty body will be returned.
The result is returned in the form of an array containing two elements. The first element is a mapping containing the headers found. The second element is a string containing the body.
Headers that occurr multiple times will have their contents NUL separated, unless use_multiple has been specified, in which case the contents will be arrays.
int|object reconstruct_partial(array(object) collection)
This function will attempt to reassemble a fragmented message from its parts.
The array collection should contain MIME.Message objects forming a complete set of parts for a single fragmented message. The order of the messages in the array is not important, but every part must exist at least once.
Should the function succeed in reconstructing the original message, a new MIME.Message object will be returned.
If the function fails to reconstruct an original message, an integer indicating the reason for the failure will be returned:
|
Note that the returned message may in turn be a part of another, larger, fragmented message.
MIME.Message->is_partial()
string decode_base64(string encoded_data)
This function decodes data encoded using the base64 transfer encoding.
MIME.encode_base64() , MIME.decode()
string encode_base64(string data, void|int no_linebreaks)
This function encodes data using the base64 transfer encoding.
If a nonzero value is passed as no_linebreaks , the result string will not contain any linebreaks.
MIME.decode_base64() , MIME.encode()
string decode_qp(string encoded_data)
This function decodes data encoded using the quoted-printable (a.k.a. quoted-unreadable) transfer encoding.
MIME.encode_qp() , MIME.decode()
string encode_qp(string data, void|int no_linebreaks)
This function encodes data using the quoted-printable (a.k.a. quoted-unreadable) transfer encoding.
If a nonzero value is passed as no_linebreaks , the result string will not contain any linebreaks.
Please do not use this function. QP is evil, and there's no excuse for using it.
MIME.decode_qp() , MIME.encode()
string decode_uue(string encoded_data)
This function decodes data encoded using the x-uue transfer encoding. It can also be used to decode generic UUEncoded files.
MIME.encode_uue() , MIME.decode()
string encode_uue(string encoded_data, void|string filename)
This function encodes data using the x-uue transfer encoding.
The optional argument filename specifies an advisory filename to include in the encoded data, for extraction purposes.
This function can also be used to produce generic UUEncoded files.
MIME.decode_uue() , MIME.encode()
array(string|int) tokenize(string header, int|void flags)
A structured header field, as specified by RFC822, is constructed from a sequence of lexical elements.
The header value to parse.
An optional set of flags. Currently only one flag is defined:
|
The lexical elements parsed are:
individual special characters
quoted-strings
domain-literals
comments
atoms
This function will analyze a string containing the header value, and produce an array containing the lexical elements.
Individual special characters will be returned as characters (i.e.
ints).
Quoted-strings, domain-literals and atoms will be decoded and returned as strings.
Comments are not returned in the array at all.
As domain-literals are returned as strings, there is no way to tell the domain-literal [127.0.0.1] from the quoted-string "[127.0.0.1]". Hopefully this won't cause any problems. Domain-literals are used seldom, if at all, anyway...
The set of special-characters is the one specified in RFC1521
(i.e. "<", ">", "@", ",", ";", ":", "\", "/", "?", "="),
and not the set specified in RFC822.
MIME.quote() , tokenize_labled() , decode_words_tokenized_remapped() .
array(array(string|int)) tokenize_labled(string header, int|void flags)
Similar to tokenize() , but labels the contents, by making arrays with two elements; the first a label, and the second the value that tokenize() would have put there, except for that comments are kept.
The header value to parse.
An optional set of flags. Currently only one flag is defined:
|
The following labels exist:
|
MIME.quote() , tokenize() , decode_words_tokenized_labled_remapped()
string quote(array(string|int) lexical_elements)
This function is the inverse of the MIME.tokenize function.
A header field value is constructed from a sequence of lexical elements.
Characters (ints) are taken to be special-characters, whereas
strings are encoded as atoms or quoted-strings, depending on whether
they contain any special characters.
There is no way to construct a domain-literal using this function. Neither can it be used to produce comments.
MIME.tokenize()
string quote_labled(array(array(string|int)) tokens)
This function performs the reverse operation of tokenize_labled() .
MIME.quote() , MIME.tokenize_labled()
string ext_to_media_type(string extension)
Returns the MIME media type for the provided filename extension . Currently 469 file extensions are known to this method. Zero will be returned on unknown file extensions.
| CLASS MIME.Message |
This class is used to hold a decoded MIME message.
mapping(string:string) MIME.Message.headers
This mapping contains all the headers of the message.
The key is the header name (in lower case) and the value is the header value.
Although the mapping contains all headers, some particular headers get special treatment by the module and should not be accessed through this mapping. These fields are currently:
|
The contents of these fields can be accessed and/or modified through a set of variables and methods available for this purpose.
type , subtype , charset , boundary , transfer_encoding , params , disposition , disp_params , setencoding() , setparam() , setdisp_param() , setcharset() , setboundary()
array(object) MIME.Message.body_parts
If the message is of type multipart, this is an array
containing one Message object for each part of the message.
If the message is not a multipart, this field is 0 (zero).
type , boundary
string MIME.Message.boundary
For multipart messages, this Content-Type parameter gives a delimiter string for separating the individual messages. As multiparts are handled internally by the module, you should not need to access this field.
setboundary()
string MIME.Message.charset
One of the possible parameters of the Content-Type header is the charset attribute. It determines the character encoding used in bodies of type text.
If there is no Content-Type header, the value of this field
is "us-ascii".
type
string MIME.Message.type
The Content-Type header contains a type, a subtype, and optionally some parameters. This field contains the type attribute extracted from the header.
If there is no Content-Type header, the value of this field
is "text".
subtype , params
string MIME.Message.subtype
The Content-Type header contains a type, a subtype, and optionally some parameters. This field contains the subtype attribute extracted from the header.
If there is no Content-Type header, the value of this field
is "plain".
type , params
string MIME.Message.transfer_encoding
The contents of the Content-Transfer-Encoding header.
If no Content-Transfer-Encoding header is given, this field
is 0 (zero).
Transfer encoding and decoding is done transparently by the module, so this field should be interesting only to applications wishing to do auto conversion of certain transfer encodings.
setencoding()
mapping(string:string) MIME.Message.params
A mapping containing all the additional parameters to the Content-Type header.
Some of these parameters have fields of their own, which should be accessed instead of this mapping wherever applicable.
charset , boundary , setparam()
string MIME.Message.disposition
The first part of the Content-Disposition header, hinting on how this part of a multipart message should be presented in an interactive application.
If there is no Content-Disposition header, this field
is 0.
mapping(string:string) MIME.Message.disp_params
A mapping containing all the additional parameters to the Content-Disposition header.
setdisp_param() , get_filename()
string get_filename()
This method tries to find a suitable filename should you want to save the body data to disk.
It will examine the filename attribute of the Content-Disposition header, and failing that the name attribute of the Content-Type header. If neither attribute is set, the method returns 0.
An interactive application should always query the user for the actual filename to use. This method may provide a reasonable default though.
array(string|int) is_partial()
If this message is a part of a fragmented message (i.e. has a Content-Type of message/partial), an array with three elements is returned.
The first element is an identifier string. This string should be used to group this message with the other fragments of the message (which will have the same id string).
The second element is the sequence number of this fragment. The first part will have number 1, the next number 2 etc.
The third element of the array is either the total number of fragments that the original message has been split into, or 0 of this information is not available.
If this method is called in a message that is not a part of a fragmented message, it will return 0.
MIME.reconstruct_partial()
void setdata(string data)
Replaces the body entity of the data with a new piece of raw data.
The new data should comply to the format indicated by the type and subtype attributes.
Do not use this method unless you know what you are doing.
getdata() , setencoded , data
string MIME.Message.data
This variable contains the raw data of the message body entity.
The type and subtype attributes indicate how this data should be interpreted.
In Pike 7.6 and earlier you had to use getdata() and setdata() to access this value.
getdata() , setdata()
string getdata()
This method returns the raw data of the message body entity.
The type and subtype attributes indicate how this data should be interpreted.
setdata() , getencoded() , data
string getencoded()
This method returns the data of the message body entity, encoded using the current transfer encoding.
You should never have to call this function.
getdata()
void setencoding(string encoding)
Select a new transfer encoding for this message.
The Content-Transfer-Encoding header will be modified accordingly, and subsequent calls to getencoded will produce data encoded using the new encoding.
See MIME.encode() for a list of valid encodings.
getencoded() , MIME.encode()
void setparam(string param, string value)
Set or modify the named parameter of the Content-Type header.
Common parameters include charset for text messages, and boundary for multipart messages.
It is not allowed to modify the Content-Type header directly, please use this function instead.
setcharset() , setboundary() , setdisp_param()
void setdisp_param(string param, string value)
Set or modify the named parameter of the Content-Disposition header.
A common parameters is e.g. filename.
It is not allowed to modify the Content-Disposition header directly, please use this function instead.
setparam() , get_filename()
void setcharset(string charset)
Sets the charset parameter of the Content-Type header.
This is equivalent of calling setparam("charset", charset ).
setparam()
void setboundary(string boundary)
Sets the boundary parameter of the Content-Type header.
This is equivalent of calling setparam("boundary", boundary ).
setparam()
string cast(string dest_type)
Casting the message object to a string will yield a byte stream suitable for transmitting the message over protocols such as ESMTP and NNTP.
The body will be encoded using the current transfer encoding, and subparts of a multipart will be collected recursively. If the message is a multipart and no boundary string has been set, one will be generated using generate_boundary() .
create()
void MIME.Message()
void MIME.Message(string message)
void MIME.Message(string message, mapping(string:string|array(string)) headers, array(object)|void parts)
void MIME.Message(string message, mapping(string:string|array(string)) headers, array(object)|void parts, int(0..1) guess)
There are several ways to call the constructor of the Message class:
With zero arguments, you will get a dummy message with neither headers nor body. Not very useful.
With one argument, the argument is taken to be a byte stream containing a message in encoded form. The constructor will analyze the string and extract headers and body.
With two or three arguments, the first argument is taken to be the raw body data, and the second argument a desired set of headers. The keys of this mapping are not case-sensitive. If the given headers indicate that the message should be of type multipart, an array of Message objects constituting the subparts should be given as a third argument.
With the guess argument set to 1 (headers and parts may be 0 if you don't want to give any), you get a more forgiving MIME Message that will do its best to guess what broken input data really meant. It won't always guess right, but for applications like mail archives and similar where you can't get away with throwing an error at the user, this comes in handy. Only use the guess mode only for situations where you need to process broken MIME messages silently; the abuse of overly lax tools is what poisons standards.
cast()
| Module Locale |
The functions and classes in the top level of the Locale module implements a dynamic localization system, suitable for programs that needs to change locale often. It is even possible for different threads to use different locales at the same time.
The highest level of the locale system is called projects. Usually one program consists of only one project, but for bigger applications, or highly modular applications it is possible for several projects to coexist.
Every project in turn contains several unique tokens, each one representing an entity that is different depending on the currently selected locale.
// The following line tells the locale extractor what to // look for. // <locale-token project="my_project">LOCALE</locale-token>
// The localization macro. #define LOCALE(X,Y) Locale.translate("my_project", \ get_lang(), X, Y)
string get_lang() { return random(2)?"eng":"swe"; }
int(0..0) main() { write(LOCALE(0, "This is a line.")+"\n"); write(LOCALE(0, "This is another one.\n"); return 0; }
void register_project(string name, string path, void|string path_base)
Make a connection between a project name and where its localization files can be found. The mapping from project name to locale file is stored in projects.
void set_default_project_path(string path)
In the event that a translation is requested in an unregistered project, this path will be used as the project path. %P will be replaced with the requested projects name.
array(string) list_languages(string project)
Returns a list of all registered languages for a specific project.
mapping(string:object) get_objects(string lang)
Reads in and returns a mapping with all the registred projects' LocaleObjects in the language 'lang'
string translate(string project, string lang, string|int id, string fallback)
Returns a translation for the given id, or the fallback string
function call(string project, string lang, string name, void|function|string fb)
Returns a localized function If function not found, tries fallback function fb, or fallback language fb instead
| CLASS Locale.DeferredLocale |
This class simulates a multi-language "string". The actual language to use is determined as late as possible.
protected string Locale.DeferredLocale.project
protected function(:string) Locale.DeferredLocale.get_lang
protected string|int Locale.DeferredLocale.key
protected string Locale.DeferredLocale.fallbackvoid Locale.DeferredLocale(string project, function(:string) get_lang, string|int key, string fallback)
array get_identifier()
Return the data nessesary to recreate this "string".
| Module Locale.Language |
| CLASS Locale.Language.abstract |
Abstract language locale class, inherited by all the language locale classes.
constant Locale.Language.abstract.months
Array(string) with the months of the year, beginning with January.
constant Locale.Language.abstract.days
Array(string) with the days of the week, beginning with Sunday.
constant Locale.Language.abstract.iso_639_1
String with the language code in ISO-639-1 (two character code). Note that all languages does not have a ISO-639-1 code.
constant Locale.Language.abstract.iso_639_2
String with the language code in ISO-639-2/T (three character code).
constant Locale.Language.abstract.iso_639_2B
String with the language code in ISO-639-2/B (three character code). This is usually the same as the ISO-639-2/T code (iso_639_2 ).
constant Locale.Language.abstract.english_name
The name of the language in english.
constant Locale.Language.abstract.name
The name of the langauge. E.g. "svenska" for Swedish.
constant Locale.Language.abstract.languages
Mapping(string:string) that maps an ISO-639-2/T id code to the name of that language.
string month(int(1..12) num)
Returns the name of month number num .
string short_month(int(1..12) num)
Returns an abbreviated month name from the month number num .
string day(int(1..7) num)
Returns the name of weekday number num .
string short_day(int(1..7) num)
Returns an abbreviated weekday name from the weekday number num .
string number(int i)
Returns the number i as a string.
string ordered(int i)
Returns the ordered number i as a string.
string date(int timestamp, string|void mode)
Returns the date for posix time timestamp as a textual string.
Determines what kind of textual string should be produced.
|
> Locale.Language.eng()->date(time()); Result: "today, 06:36"
| Module Locale.Language.srp |
Serbian language locale by Goran Opacic 1996/12/11
inherit "abstract"
| Module Locale.Language.eng |
English language locale.
inherit "abstract"
| Module Locale.Language.mri |
Maaori (New Zealand) language locale by Jason Rumney
inherit "abstract"
| Module Locale.Language.slv |
Slovenian language locale by Iztok Umek 7. 8. 1997
inherit "abstract"
| Module Locale.Language.nor |
Norwegian language locale
inherit "abstract"
| Module Locale.Language.deu |
German language locale by Tvns Böker.
inherit "abstract"
| Module Locale.Language.ces |
Czech language locale by Jan Petrous 16.10.1997, based on Slovenian language module by Iztok Umek.
inherit "abstract"
| Module Locale.Language.swe |
Swedish language locale
inherit "abstract"
| Module Locale.Language.nld |
Dutch language locale by Stephen R. van den Berg
inherit "abstract"
| Module Locale.Language.spa |
Spanish language locale
inherit "abstract"
| Module Locale.Language.rus |
Russian language locale
inherit "abstract"
| Module Locale.Language.fin |
Finnish language locale created by Janne Edelman, Turku Unix Users Group ry, Turku, Finland
inherit "abstract"
| Module Locale.Language.fra |
French language locale by Patrick Kremer.
inherit "abstract"
| Module Locale.Language.hun |
Hungarian language locale by Zsolt Varga.
inherit "abstract"
| Module Locale.Language.hrv |
Croatian language locale by Klara Makovac 1997/07/02
inherit "abstract"
| Module Locale.Language.ita |
Italian language locale by Francesco Chemolli
inherit "abstract"
| Module Locale.Language.cat |
Catalan language locale.
inherit "abstract"
| Module Locale.Language.pol |
Polish language locale by Piotr Klaban.
inherit "abstract"
| Module Locale.Language.por |
Portuguese language locale
inherit "abstract"
| Module Locale.Language.jpn |
Japanese language locale.
inherit "abstract"
| Module Locale.Charset |
The Charset module supports a wide variety of different character sets, and
it is flexible in regard of the names of character sets it accepts. The
character case is ignored, as are the most common non-alaphanumeric
characters appearing in character set names. E.g. "iso-8859-1"
works just as well as "ISO_8859_1". All encodings specified in
RFC 1345 are supported.
First of all the Charset module is capable of handling the following encodings of Unicode:
UTF encodings
Most, if not all, of the relevant code pages are represented, as the following list shows. Prefix the numbers as noted in the list to get the wanted codec:
These may be prefixed with "cp", "ibm" or
"ms".
These may be prefixed with "cp", "ibm",
"ms" or "windows"
The default charset in MySQL, similar to cp1252.
+359 more.
string normalize(string in)
All character set names are normalized through this function before compared.
void set_decoder(string name, Decoder decoder)
Adds a custom defined character set decoder. The name is normalized through the use of normalize .
Decoder decoder(string name)
Returns a charset decoder object.
The name of the character set to decode from. Supported charsets include (not all supported charsets are enumerable): "iso_8859-1:1987", "iso_8859-1:1998", "iso-8859-1", "iso-ir-100", "latin1", "l1", "ansi_x3.4-1968", "iso_646.irv:1991", "iso646-us", "iso-ir-6", "us", "us-ascii", "ascii", "cp367", "ibm367", "cp819", "ibm819", "iso-2022" (of various kinds), "utf-7", "utf-8" and various encodings as described by RFC1345.
If the asked-for name was not supported, an error is thrown.
void set_encoder(string name, Encoder encoder)
Adds a custom defined character set encoder. The name is normalized through the use of normalize .
Encoder encoder(string name, string|void replacement, function(string:string)|void repcb)
Returns a charset encoder object.
The name of the character set to encode to. Supported charsets include (not all supported charsets are enumerable): "iso_8859-1:1987", "iso_8859-1:1998", "iso-8859-1", "iso-ir-100", "latin1", "l1", "ansi_x3.4-1968", "iso_646.irv:1991", "iso646-us", "iso-ir-6", "us", "us-ascii", "ascii", "cp367", "ibm367", "cp819", "ibm819", "iso-2022" (of various kinds), "utf-7", "utf-8" and various encodings as described by RFC1345.
The string to use for characters that cannot be represented in the charset. It's used when repcb is not given or when it returns zero. If no replacement string is given then an error is thrown instead.
A function to call for every character that cannot be represented in the charset. If specified it's called with one argument - a string containing the character in question. If it returns a string then that one will replace the character in the output. If it returns something else then the replacement argument will be used to decide what to do.
If the asked-for name was not supported, an error is thrown.
Decoder decoder_from_mib(int mib)
Returns a decoder for the encoding schema denoted by MIB mib .
Encoder encoder_from_mib(int mib, string|void replacement, function(string:string)|void repcb)
Returns an encoder for the encoding schema denoted by MIB mib .
void decode_error(string err_str, int err_pos, string charset, void|string reason, void|mixed ... args)
Throws a DecodeError exception. See DecodeError.create for
details about the arguments. If args is given then the error
reason is formatted using sprintf(reason , @args ).
void encode_error(string err_str, int err_pos, string charset, void|string reason, void|mixed ... args)
Throws an EncodeError exception. See EncodeError.create for
details about the arguments. If args is given then the error
reason is formatted using sprintf(reason , @args ).
| CLASS Locale.Charset.Decoder |
Virtual base class for charset decoders.
string win1252_to_string( string data ) { return Locale.Charset.decoder("windows-1252")->feed( data )->drain(); }
string Locale.Charset.Decoder.charset
Name of the charset - giving this name to decoder returns an instance of the same class as this object.
This is not necessarily the same name that was actually given to decoder to produce this object.
this_program feed(string s)
Feeds a string to the decoder.
String to be decoded.
Returns the current object, to allow for chaining of calls.
string drain()
Get the decoded data, and reset buffers.
Returns the decoded string.
this_program clear()
Clear buffers, and reset all state.
Returns the current object to allow for chaining of calls.
| CLASS Locale.Charset.Encoder |
Virtual base class for charset encoders.
inherit Decoder : Decoder
An encoder only differs from a decoder in that it has an extra function.
string Locale.Charset.Encoder.charset
Name of the charset - giving this name to encoder returns an instance of the same class as this one.
This is not necessarily the same name that was actually given to encoder to produce this object.
void set_replacement_callback(function(string:string) rc)
Change the replacement callback function.
Function that is called to encode characters outside the current character encoding.
| CLASS Locale.Charset.DecodeError |
Error thrown when decode fails (and no replacement char or replacement callback has been registered).
This error class is not actually used by this module yet - decode errors are still thrown as untyped error arrays. At this point it exists only for use by other modules.
inherit Error.Generic : Generic
string Locale.Charset.DecodeError.err_str
The string that failed to be decoded.
int Locale.Charset.DecodeError.err_pos
The failing position in err_str .
string Locale.Charset.DecodeError.charset
The decoding charset, typically as known to Locale.Charset.decoder .
Other code may produce errors of this type. In that case this name is something that Locale.Charset.decoder does not accept (unless it implements exactly the same charset), and it should be reasonably certain that Locale.Charset.decoder never accepts that name in the future (unless it is extended to implement exactly the same charset).
| CLASS Locale.Charset.EncodeError |
Error thrown when encode fails (and no replacement char or replacement callback has been registered).
This error class is not actually used by this module yet - encode errors are still thrown as untyped error arrays. At this point it exists only for use by other modules.
inherit Error.Generic : Generic
string Locale.Charset.EncodeError.err_str
The string that failed to be encoded.
int Locale.Charset.EncodeError.err_pos
The failing position in err_str .
string Locale.Charset.EncodeError.charset
The encoding charset, typically as known to Locale.Charset.encoder .
Other code may produce errors of this type. In that case this name is something that Locale.Charset.encoder does not accept (unless it implements exactly the same charset), and it should be reasonably certain that Locale.Charset.encoder never accepts that name in the future (unless it is extended to implement exactly the same charset).
| Module Locale.Charset.Tables |
| Module Locale.Charset.Tables.iso88591 |
Codec for the ISO-8859-1 character encoding.
| Module Locale.Gettext |
This module enables access to localization functions from within Pike.
The message conversion functions in this module do not handle Unicode strings. They only provide thin wrappers to gettext(3) etc, which means strings are assumed to be encoded according to the LC_* and LANG variables. See the docs for gettext(3) for details.
string gettext(string msg)
string gettext(string msg, string domain)
string gettext(string msg, string domain, int category)
Message to be translated.
Domain from within the message should be translated. Defaults to the current domain.
Category from which the translation should be taken. Defaults to Locale.Gettext.LC_MESSAGES .
Return a translated version of msg within the context of the specified domain and current locale. If there is no translation available, msg is returned.
Prior to Pike 7.3 this function only accepted one argument, and the other functionality was provided by dgettext() and dcgettext() .
bindtextdomain , textdomain , setlocale , localeconv
string dgettext(string domain, string msg)
Return a translated version of msg within the context of the specified domain and current locale. If there is no translation available, msg is returned.
Obsoleted by gettext() in Pike 7.3.
bindtextdomain , textdomain , gettext , setlocale , localeconv
string dcgettext(string domain, string msg, int category)
Return a translated version of msg within the context of the specified domain and current locale for the specified category . Calling dcgettext with category Locale.Gettext.LC_MESSAGES gives the same result as dgettext.
If there is no translation available, msg is returned.
Obsoleted by gettext() in Pike 7.3.
bindtextdomain , textdomain , gettext , setlocale , localeconv
string textdomain(void|string domain)
The textdomain() function sets or queries the name of the current domain of the active LC_MESSAGES locale category. The domain argument is a string that can contain only the characters allowed in legal filenames.
The domain argument is the unique name of a domain on the system. If there are multiple versions of the same domain on one system, namespace collisions can be avoided by using bindtextdomain() . If textdomain() is not called, a default domain is selected. The setting of domain made by the last valid call to textdomain() remains valid across subsequent calls to setlocale() , and gettext() .
The normal return value from textdomain() is a string containing the current setting of the domain. If domainname is void, textdomain() returns a string containing the current domain. If textdomain() was not previously called and domainname is void, the name of the default domain is returned.
bindtextdomain , gettext , setlocale , localeconv
string bindtextdomain(string|void domainname, string|void dirname)
Binds the path predicate for a message domainname domainname to the directory name specified by dirname .
If domainname is a non-empty string and has not been bound previously, bindtextdomain() binds domainname with dirname .
If domainname is a non-empty string and has been bound previously, bindtextdomain() replaces the old binding with dirname .
The dirname argument can be an absolute or relative pathname being resolved when gettext() , dgettext() or dcgettext() are called.
If domainname is zero or an empty string, bindtextdomain() returns 0.
User defined domain names cannot begin with the string "SYS_".
Domain names beginning with this string are reserved for system use.
The return value from bindtextdomain() is a string containing dirname or the directory binding associated with domainname if dirname is unspecified. If no binding is found, the default locale path is returned. If domainname is unspecified or is an empty string, bindtextdomain() takes no action and returns a 0.
textdomain , gettext , setlocale , localeconv
int setlocale(int category, string locale)
The setlocale() function is used to set the program's current locale. If locale is "C" or "POSIX", the current locale is set to the portable locale.
If locale is "", the locale is set to the default locale which is selected from the environment variable LANG.
The argument category determines which functions are influenced by the new locale are LC_ALL , LC_COLLATE , LC_CTYPE , LC_MONETARY , LC_NUMERIC and LC_TIME .
Returns 1 if the locale setting successed, 0 for failure
bindtextdomain , textdomain , gettext , dgettext , dcgettext , localeconv
mapping localeconv()
The localeconv() function returns a mapping with settings for the current locale. This mapping contains all values associated with the locale categories LC_NUMERIC and LC_MONETARY .
|
bindtextdomain , textdomain , gettext , dgettext , dcgettext , setlocale
constant Locale.Gettext.LC_ALL
Locale category for all of the locale.
constant Locale.Gettext.LC_COLLATE
Locale category for the functions strcoll() and strxfrm() (used by pike, but not directly accessible).
constant Locale.Gettext.LC_CTYPE
Locale category for the character classification and conversion routines.
constant Locale.Gettext.LC_MESSAGES
Document this constant.
This category isn't available on all platforms.
constant Locale.Gettext.LC_MONETARY
Locale category for localeconv().
constant Locale.Gettext.LC_NUMERIC
Locale category for the decimal character.
constant Locale.Gettext.LC_TIME
Locale category for strftime() (currently not accessible from Pike).
| Module GLUE |
GL Universal Environment
array(string) get_drivers()
Returns the name of the available drivers.
init
void add_reinit_callback(function(void:void) f)
Add a callback that will be called every time the resolution is about to change.
remove_reinit_callback
void remove_reinit_callback(function(void:void) f)
Removes a reinitialization callback.
add_reinit_callback
int(0..1) has_extension(string ext)
Checks if the GL extension ext is currently supported.
int(0..1) get_screen_mode()
Returns 1 if in fullscreen mode, otherwise 0.
toggle_fullscreen
void toggle_fullscreen(void|int(0..1) _fullscreen)
Toggles between fullscreen and window mode. If a screen mode is provided, that mode will be assumed.
get_screen_mode
int get_gl_flags()
Returns the GL flags currently used.
set_gl_flags
void set_gl_flags(int _gl_flags)
Sets the GL flags.
get_gl_flags
int get_depth()
Returns the current color depth.
set_depth
void set_depth(int _depth)
Sets the color depth.
get_depth
int xsize()
int ysize()
Returns the screen width/height.
set_resolution
void set_resolution(int w, int h)
Sets the resolution to w xh pixels.
xsize , ysize
float get_aspect()
Returns the screen aspect.
set_aspect
void set_aspect(float asp)
void set_aspect(int w, int h)
Set the aspect of the draw area. Does nothing if the provided aspect is equal to the one currently used.
get_aspect
void set_screen_rotation(float deg)
Rotates the drawing area deg degrees. Useful e.g. when drawing for tilted monitors.
void mirror_screen(string how)
Mirrors the screen in x and/or y axis. Useful e.g. when drawing for backlight projection.
A string that contains the mirror axis, e.g. "x" or
"xy".
void init(void|mapping(string:mixed) options)
Initializes GLUE and loads a driver from a list of drivers. If a driver fails to load or initialize, the next driver is tried.
driver_names not listed in the result from get_drivers will cause an error to be thrown.
|
get_drivers
void swap_buffers()
Swap the drawing buffer and the viewing buffer.
void show_cursor()
Show the mouse cursor.
void hide_cursor()
Hide the mouse cursor.
int allocate_light()
Allocate a hardwareaccelerated lightsource from OpenGL.
an id which may be added to the GL.GL_LIGHT0 constant.
free_light
void free_light(int l)
Call this function to free a lightsource that has been allocated with allocate_light .
Id which has been allocated using allocate_light .
allocate_light
int(0..) pushpop_depth()
Returns the PushPop depth, i.e. the number of pushes awaiting corresponding pops.
void PushPop(function f)
Performs function f between GL.glPushMatrix and GL.glPopMatrix calls.
PushPop() { GL.glTranslate( 0.01, -0.9, 0.0 ); write_text( "Press esc to quit" ); };
array(List) get_all_lists()
Returns all defined lists. Only available on Windows.
int(0..1) only_dynlists()
Returns 1 if all defined lists are DynList lists.
BaseTexture make_texture(mapping|Image.Image image, string|void name)
Create a texture. Mainly here for symetry with make_rect_texture
Texture , make_rect_texture
BaseTexture make_rect_texture(mapping|Image.Image image, string|void name)
Create a texture with the specified image as contents. Will try to use the TEXTURE_RECTANGLE_NV extension if available, otherwise normal textures will be used (like make_texture ).
make_texture
array(BaseTexture) get_all_textures()
Returns a list of all current textures.
int get_texture_mem_usage()
Returns the number of bytes used by the textures.
void draw_line(float x0, float y0, float x1, float y1, Image.Color.Color c, void|float a)
void draw_line(float x0, float y0, float z0, float x1, float y1, float z1, Image.Color.Color c, void|float a)
void draw_obox(float x0, float y0, float x1, float y1, array(Image.Color.Color)|Image.Color.Color c, void|array(float)|float a)
Draw a box outline around the specified coordinates. c is either a single color, in which case it will be used for all corners, or an array of four colors, which will be used for each corner.
a is similar to c , but is the alpha values for each coordinate.
void draw_box(float x0, float y0, float x1, float y1, array(Image.Color.Color)|Image.Color.Color c, void|array(float)|float a)
Draw a box at the specified coordinates. c is either a single color, in which case it will be used for all corners, or an array of four colors, which will be used for each corner.
a is similar to c , but is the alpha values for each coordinate.
void draw_polygon(array(float) coords, Image.Color.Color c, float a)
mapping(string:mixed) debug_stuff()
Returns some internal states for debug purposes. The actual content may change.
| CLASS GLUE.List |
A display list abstraction. Automatically allocates a display list id upon creation and correctly deallocate it upon destruction.
DynList
void GLUE.List(void|function f)
When creating a new list, the list code can be compiled upon creation by supplying a function f that performs the GL operations.
call
List list = List() { // GL code };
void destroy()
Deletes this list and frees the list id from the id pool.
int get_id()
Returns this lists' id.
int(0..1) `>(mixed x)
List objects can be sorted according to list id.
get_id
void begin(int(0..1)|void run)
Start defining the list. If run is provided, the list will be executed as it is compiled (GL.GL_COMPILE_AND_EXECUTE ).
end , compile
void end()
Finish the list definition.
begin , compile
void compile(function f)
Compile a list be executing the list code f . Exceptions in f will be thrown after GL.glEndList has been called.
begin
void call()
Execute the commands in the list.
| CLASS GLUE.DynList |
A displaylist that is generated on demand.
On Windows lists needs to be regenerated when the video driver mode is changed. Thus the DynList is to prefer over List , since regeneration is done automatically upon video mode change.
inherit List : List
void modeswitch()
Called by videodriver when a video mode change occurs.
void set_generator(function _generator)
Sets a function which can generate a displaylist. Hint: Use implicit lambda...
void init()
Generates the displaylist, ie calls the function set in set_generator . Called only when the display list needs to be generated.
void call()
Call the displaylist, ie draw it.
void GLUE.DynList(function|void f)
Create a new DynList object and optionally set a function that can generate the displaylist
Function which contains the GL commands that generates the displaylist.
| CLASS GLUE.BaseTexture |
The texture base class. Using e.g. Texture might be more convenient.
int GLUE.BaseTexture.t_width
int GLUE.BaseTexture.t_height
Texture dimensions
int GLUE.BaseTexture.i_width
int GLUE.BaseTexture.i_height
Image dimensions
float GLUE.BaseTexture.width_u
float GLUE.BaseTexture.height_u
Utilization in percent.
int GLUE.BaseTexture.texture_type
The texture type, e.g. GL.GL_TEXTURE_2D .
string GLUE.BaseTexture.debug
A string to identify the texture.
void construct(int width, int height, int _alpha, mapping|void imgs, int(0..3)|void flags, int|void _mode, string|void debug_text)
Construct a new texture. Processes _alpha , _mode and debug_text and calls resize .
The alpha mode the texture is operating in.
|
The mode the texture is operating in. Autoselected wrt _alpha
if 0.
A string that can be used to identify this texture.
void GLUE.BaseTexture(mixed ... args)
Calls construct with args .
void destroy()
Properly deallocates the texture.
void resize(int width, int height, mapping|void imgs, int(0..3)|void flags, int(0..1)|void nocreate)
Resizes/creates a texture to meet the dimensions width and height . If nocreate isn't given, create_texture is called to actually perform the resize/creation.
construct
void create_texture(mapping|void imgs, int(0..3)|void flags, int|void width, int|void height)
Actually creates the texture.
If zero, a black texture with the dimensions width * height will be generated. Otherwise imgs should be a mapping as follows.
|
If 1, the texture will be mipmapped.
If bit 1 (2) is set, texture will not be wrapped but clamped.
The dimensions of the texture. If omitted the dimensions of the images in imgs will be used.
resize
void make_mipmap(mapping imgs, int|void imode, int|void dx, int|void dy)
Renders a mipmap of the image/partial image imgs .
Image data mapping to feed GL.glTexImage2D or GL.glTexSubImage2D .
Internal format to feed GL.glTexImage2D , or UNDEFINED for partial images.
Xoffs, yoffs to feed GL.glTexSubImage2D for partial images.
create_texture
void clear()
Clears the texture.
void paste(Image.Image i, Image.Image a, int x, int y)
Paste the image i with alpha channel a at coordinates x and y in the current texture.
int _sizeof()
Returns the size of memory allocated by the texture.
int get_id()
Returns the id of this texture.
int(0..1) `>(mixed x)
Textures can be sorted according to texture id.
void draw(float x, float y, float z, float w, float h)
Draw the texture at x ,y ,z with dimensions w *h .
void draw_region(float x, float y, float z, float w, float h, float s0, float q0, float ss, float qs)
Draw texture region s0 ,q0 - ss ,qs at x ,y ,z with dimensions w *h .
void use()
Use the generated texture (GL.glBindTexture ).
void coords(float x, float y)
Sets the texture coordinates to x *width,y *height.
void set_image_data(Image.Image|mapping(string:mixed) data, int(0..1)|void no_resize)
Set the contents (and size) of the texture from the supplied data. The data is identical to what would normally be sent as the last argument to glTex[Sub]Image2D() or an Image.Image object.
If no_resize is specified, it is assumed that the data will fit in the texture, otherwise the parts that extend beyond it will be discarded.
Besides being an Image.Image object, data can be either of two types of mappins. First it can be a mapping with Image data.
|
Second it can be a mapping pointing out a shared memory segment.
|
| CLASS GLUE.RectangleTexture |
Uses the NVidia RECT texture extension for non-power-of-two textures.
inherit BaseTexture : BaseTexture
| CLASS GLUE.BaseDWIM |
A mixin class with a dwim create function.
void GLUE.BaseDWIM(mixed ... args)
This create function has the following heuristic:
If a mapping is encountered, the following information will be attempted to be extracted.
|
If an object is encountered in the argument list, the first object will be used as texture image and the second as texture alpha.
If a string is encountered in the argument list, it will be used as debug name associated with this texture.
Once all mappings, strings and objects are removed from the argument list, the remaining integers will be interpreted as width, height, alpha, mipmap and mode, unless there is only one argument. In that case it will be interpreted as the alpha mode.
| CLASS GLUE.Texture |
Convenience version of the Texture class.
inherit BaseTexture : BaseTexture
Texture base
inherit BaseDWIM : BaseDWIM
Convenience methods
| CLASS GLUE.RectangleDWIMTexture |
Convenience version of the RectangleTexture class.
inherit RectangleTexture : RectangleTexture
Texture base
inherit BaseDWIM : BaseDWIM
Convenience methods
| CLASS GLUE.Region |
A rectangle. Used by the text routines to avoid drawing outside the current region.
float GLUE.Region.x
float GLUE.Region.y
float GLUE.Region.w
float GLUE.Region.hvoid GLUE.Region(float x, float y, float w, float h)
constant GLUE.Region.is_region
All region objects have this constant.
void move(float xp, float yp)
Move the region xp units right and yp units down.
void resize(float xs, float ys)
Make the region xs units wider and ys units higher.
int(0..1) outside(Region R)
Returns 1 if the region R is fully outside this region.
int(0..1) inside(Region R)
Returns 1 if the region R is fully inside this region.
Region `&(mixed R)
Creates a new region with the intersection of this region and R .
| CLASS GLUE.Font |
A font.
void GLUE.Font(Image.Fonts.Font f, float|void _scale_width, float|void _scale_spacing)
array(int|BaseTexture|Region) get_character(int c)
Returns the advance (in pixels), the texture and the texture coordinates for the specified character, or 0 if it's nonprintable.
If the font->write call fails, the backtrace will be written to stderr.
array(float) text_extents(string text, float h)
Get the width and height of the area that the string text in size h would cover.
array(float) write_now(string text, float h, void|float|Region roi, string|void align)
Write the text in size [h], possibly restricted by region roi .
Return the width and height of the resulting text area. If roi is
a float, Region(0.0, 0.0, roi, 10000.0) will be used.
array(List|float) write(string text, float h, void|float|Region roi, string|void align)
Create a display list that writes text.
The text to write.
The font height
The region, if supplied, to restrict writing to.
The text justification; "left" (default), "center" or "right".
| CLASS GLUE.Font.Character |
A character to draw.
inherit Region : Region
Region GLUE.Font.Character.pos
Character position in texture txt .
BaseTexture GLUE.Font.Character.txt
Texture holding the character.
Region GLUE.Font.Character.slice
Slice of character to be shown.
void set_data(Region _pos, BaseTexture _txt, void|Region _slice)
Set character to be region _slice of region _pos of texture _txt .
void draw()
Draw the character using the texture txt with the texture-coordinates indicated in pos , possible cropped with slice .
| CLASS GLUE.SquareMesh |
A mesh of squares.
void recalculate()
Recalculate the mesh.
Math.Matrix surface_normal(int x, int y)
Return the normal for the surface at coordinates x,y. Used internally.
void set_texture(BaseTexture tex)
Set a texture to be mapped on the mesh.
void draw()
Draw the mesh.
void set_lighting(int(0..1) do_lighting)
Indicate whether or not lighting is used. If it is, the normals of each vertex will be calculated as well as the coordinates.
void set_size(int x, int y)
Set the size of the mesh
void GLUE.SquareMesh(function(float:Math.Matrix) calculator)
The calculator will be called for each corner and should return a 1x3 matrix describing the coordinates for the given spot om the surface.
| Module GLUE.Events |
GLUE Event abstraction.
constant GLUE.Events._SHFT
Integer constant representing shift.
constant GLUE.Events._CTRL
Integer constant representing control.
constant GLUE.Events._ALT
Integer constant representing alternate.
constant GLUE.Events.KNOWN_MODIFIERS
Integer constant with the union of all known modifiers, i.e.
_SHFT | _CTRL | _ALT.
Event CTRL(int|Event X)
array(Event) CTRL(array(int|Event) X)
Adds the _CTRL modifier to an Event , key or array of Events and/or keys.
Event SHFT(int|Event X)
array(Event) SHFT(array(int|Event) X)
Adds the _SHFT modifier to an Event , key or array of Events and/or keys.
Event ALT(int|Event X)
array(Event) ALT(array(int|Event) X)
Adds the _ALT modifier to an Event , key or array of Events and/or keys.
constant GLUE.Events.BACKSPACE
constant GLUE.Events.DELETE
constant GLUE.Events.TAB
constant GLUE.Events.F1
constant GLUE.Events.F2
constant GLUE.Events.F3
constant GLUE.Events.F4
constant GLUE.Events.F5
constant GLUE.Events.F6
constant GLUE.Events.F7
constant GLUE.Events.F8
constant GLUE.Events.F9
constant GLUE.Events.F10
constant GLUE.Events.F11
constant GLUE.Events.F12
constant GLUE.Events.ESCAPE
constant GLUE.Events.UP
constant GLUE.Events.DOWN
constant GLUE.Events.LEFT
constant GLUE.Events.RIGHT
constant GLUE.Events.PGUP
constant GLUE.Events.PGDWN
constant GLUE.Events.ENTER
constant GLUE.Events.SPACE
constant GLUE.Events.HOME
constant GLUE.Events.END
constant GLUE.Events.PAUSE
constant GLUE.Events.INSERT
constant GLUE.Events.SCROLL_LOCK
constant GLUE.Events.SYS_REQ
constant GLUE.Events.PRINT_SCRN
constant GLUE.Events.CAPSLOCK
constant GLUE.Events.MENU
constant GLUE.Events.NUMLOCK
constant GLUE.Events.A
constant GLUE.Events.B
constant GLUE.Events.C
constant GLUE.Events.D
constant GLUE.Events.E
constant GLUE.Events.F
constant GLUE.Events.G
constant GLUE.Events.H
constant GLUE.Events.I
constant GLUE.Events.J
constant GLUE.Events.K
constant GLUE.Events.L
constant GLUE.Events.M
constant GLUE.Events.N
constant GLUE.Events.O
constant GLUE.Events.P
constant GLUE.Events.Q
constant GLUE.Events.R
constant GLUE.Events.S
constant GLUE.Events.T
constant GLUE.Events.U
constant GLUE.Events.V
constant GLUE.Events.W
constant GLUE.Events.X
constant GLUE.Events.Y
constant GLUE.Events.Z
Numeric constant representing a key.
constant GLUE.Events.BUTTON_1
constant GLUE.Events.BUTTON_2
constant GLUE.Events.BUTTON_3
constant GLUE.Events.BUTTON_4
constant GLUE.Events.BUTTON_5
Numeric constant representing a mouse button.
constant GLUE.Events.MOUSE_UP
constant GLUE.Events.MOUSE_DOWN
constant GLUE.Events.MOUSE_LEFT
constant GLUE.Events.MOUSE_RIGHT
constant GLUE.Events.MOUSE_ABS
Numeric constant representing a mouse movement.
constant GLUE.Events.LSHIFT
constant GLUE.Events.RSHIFT
constant GLUE.Events.LCTRL
constant GLUE.Events.RCTRL
constant GLUE.Events.LALT
constant GLUE.Events.RALT
Numeric constant representing a modifier key.
constant GLUE.Events.MODIFIERS
Mapping that maps a modifier key to any of the symbolic modifiers _SHFT , _CTRL and _ALT .
constant GLUE.Events.EXIT
Numeric constant representing an exit event.
constant GLUE.Events.key_names
Mapping that maps key identifiers with a printable name, e.g.
LSHIFT to "Left shift".
int(0..1) is_modifier(int k)
Returns 1 if the key code k is a modifier key, e.g.
LSHIFT or RSHIFT .
| CLASS GLUE.Events.Event |
Contains an event.
this_program dup()
Returns a copy of this Event object.
float GLUE.Events.Event.pressure
The pressure of the key stroke. A value between 0.0 and 1.0. Unknown values are represented as 0.
int(0..1) GLUE.Events.Event.press
Press event or release event.
void GLUE.Events.Event(int|void _key, int(0..1)|void _press, string|void _data, int|void _modifiers, float|void pressure)
| Module String |
string implode_nicely(array(string|int|float) foo, string|void separator)
This function implodes a list of words to a readable string, e.g.
({"straw","berry","pie"}) becomes
"straw, berry and pie". If the separator is omitted, the
default is "and". If the words are numbers they are
converted to strings first.
`*()
string capitalize(string str)
Convert the first character in str to upper case, and return the new string.
lower_case() , upper_case()
string sillycaps(string str)
Convert the first character in each word (separated by spaces) in str to upper case, and return the new string.
string common_prefix(array(string) strs)
Find the longest common prefix from an array of strings.
int(0..100) fuzzymatch(string a, string b)
This function compares two strings using a fuzzy matching routine. The higher the resulting value, the better the strings match.
Array.diff() , Array.diff_compare_table() Array.diff_longest_sequence()
string soundex(string word)
Returns the soundex value of word according to the original Soundex algorithm, patented by Margaret O´Dell and Robert C. Russel in 1918. The method is based on the phonetic classification of sounds by how they are made. It was only intended for hashing of english surnames, and even at that it isn't that much of a help.
string int2roman(int m)
Converts the provided integer to a roman integer (i.e. a string).
Throws an error if m is outside the range 0 to 10000.
string int2size(int size)
Returns the size as a memory size string with suffix, e.g. 43210 is converted into "42.2 kB". To be correct to the latest standards it should really read "42.2 KiB", but we have chosen to keep the old notation for a while. The function knows about the quantifiers kilo, mega, giga, tera, peta, exa, zetta and yotta.
string expand_tabs(string s, int|void tab_width, string|void substitute_tab, string|void substitute_space, string|void substitute_newline)
Expands tabs in a string to ordinary spaces, according to common tabulation rules.
string int2char(int x)
Same as sprintf("%c",x);
sprintf()
string int2hex(int x)
Same as sprintf("%x",x);, i.e. returns the integer x in
hexadecimal base using lower cased symbols.
sprintf()
string string2hex(string data)
Convert a string of binary data to a hexadecimal string.
hex2string()
string hex2string(string hex)
Convert a string of hexadecimal digits to binary data.
string2hex()
void secure(string str)
Marks the string as secure, which will clear the memory area before freeing the string.
int count(string haystack, string needle)
Count the number of non-overlapping times the string needle
occurs in the string haystack . The special cases for the needle
"" is that it occurs one time in the empty string, zero
times in a one character string and between every character
(length-1) in any other string.
search() , `/()
string trim_whites(string s)
Trim leading and trailing spaces and tabs from the string s .
string trim_all_whites(string s)
Trim leading and trailing white spaces characters (space, tab, newline and carriage return) from the string s .
int(8..8)|int(16..16)|int(32..32) width(string s)
Returns the width of a string.
Three return values are possible:
|
| CLASS String.Iterator |
An object of this class is returned by get_iterator() when called with a string.
get_iterator
inherit predef::Iterator : predef::Iterator
| CLASS String.SplitIterator |
An iterator that iterates over substrings of a string, separated by a character or several different characters.
Typically you don't need to explicitly use the SplitIterator. Expressions like the following are automatically optimized into using a SplitIterator.
foreach(str/"\n", string line)
write("%s\n", line);
inherit predef::Iterator : predef::Iterator
void String.SplitIterator(string buffer, int|array(int)|multiset(int) split_set, int|void flags, function(:string)|void feed)
The string to split.
The character or characters to split on.
Skip empty elements if set.
Callback function that is called once the buffer is used up and the SplitIterator wants more data.
| CLASS String.Buffer |
A buffer, used for building strings. It's conceptually similar to a string, but you can only add strings to it, and you can only get the value from it once.
There is a reason for those seemingly rather odd limitations, it makes it possible to do some optimizations that really speed things up.
You do not need to use this class unless you add very many strings together, or very large strings.
For the fastest possible operation, write your code like this:
String.Buffer b = String.Buffer( );
function add = b->add;
.. call add several times in code ...
string result = b->get(); // also clears the buffer
void String.Buffer(int initial_size)
Initializes a new buffer.
If no initial_size is specified, 256 is used. If you know approximately how big the buffer will be, you can optimize the operation of add() (slightly) by passing the size to this function.
string _sprintf(int flag, mapping flags)
It is possible to sprintf a String.Buffer object as %s just as if it was a string.
mixed cast(string type)
It is possible to cast a String.Buffer object to
a string and an int.
String.Buffer `+(string what)
String.Buffer `+=(string what)
int add(string ... data)
Adds data to the buffer. Returns the size of the buffer.
void putchar(int c)
Appends the character c at the end of the string.
string get_copy()
Get the data from the buffer. Significantly slower than get , but does not clear the buffer.
string get()
Get the data from the buffer.
This will clear the data in the buffer
int _sizeof()
Returns the size of the buffer.
| CLASS String.Replace |
This is a "compiled" version of the replace function applied on
a string, with more than one replace string. The replace strings
are given to the create method as a from and to array
and are then analyzed. The `() is then called with a
string and the replace rules in the Replace object will be
applied. The Replace object is used internally by the Pike
optimizer and need not be used manually.
void String.Replace(array(string)|mapping(string:string)|void from, array(string)|string|void to)
string `()(string str)
array(array(string)) _encode()
void _decode(array(array(string)) encoded)
| CLASS String.SingleReplace |
This is a "compiled" version of the replace function applied on
a string, with just one replace string. The replace strings are
given to the create method as a from and tom string and
are then analyzed. The `() is then called with a string
and the replace rule in the Replace object will be applied. The
Replace object is used internally by the Pike optimizer and need
not be used manually.
void String.SingleReplace(string|void from, string|void to)
May be called with either zero or two arguments.
string `()(string str)
array(string) _encode()
void _decode(array(string)|int(0..0) encoded)
| CLASS String.Bootstring |
This class implements the "Bootstring" string transcoder described in ftp://ftp.rfc-editor.org/in-notes/rfc3492.txt.
string decode(string s)
Decodes a Bootstring encoded string of "basic" code points back to the original string space.
string encode(string s)
Encodes a string using Bootstring encoding into a string constisting only of "basic" code points (< initial_n).
void String.Bootstring(int base, int tmin, int tmax, int skew, int damp, int initial_bias, int initial_n, int delim, string digits)
Creates a Bootstring transcoder instance using the specified parameters.
The base used by the variable-length integers.
The minimum threshold digit value for the variable-length integers. Must be >=0 and <= tmax.
The maximum threshold digit value for the variable-length integers. Must be <= base-1.
The skew term for the bias adapation. Must be >= 1.
The damping factor for the bias adaption. Must be >= 2.
The initial bias for the variable-length integer thresholding. initial_bias % base must be <= base - tmin.
The first code point outside the "basic" set of code points.
The "basic" code point used as the delimiter.
The "basic" code points used as digits. The length of the string should be the same as the base parameter.
| Module String.Elite |
string elite_word(string in, void|int(0..100) leetp, void|int(0..2) eightbit)
Translates one word to 1337. The optional argument leetp is the maximum percentage of leetness (100=max leet, 0=no leet). elite_word only do character-based translation, for instance from "k" to "|<", but no language translation (no "cool" to "kewl").
string elite_string(string in, void|int(0..100) leetp, void|int(0..1) eightbit)
Translates a string to 1337. The optional argument leetp is the maximum percentage of leetness (100=max leet, 0=no leet).
The translation is performed in three steps, first the neccesary elite translations (picture -> pic, cool->kewl etc), then optional translations (ok->k, dude->dood, -ers -> -orz), then calls elite_word on the resulting words.
| Module String.HTML |
Functions that helps generating HTML. All functions generates HTML that is XHTML compliant as well as backwards compatible with old HTML standards in what extent is possible.
string select(string name, array(string)|array(array(string)) choices, void|string selected)
Creates an HTML select list.
The name of the select list. Will be used in the name attribute of the select element.
May either be an array of strings, where each string is a choice, or an array of pairs. A pair is an array with two strings. The first string is the value of the choice while the second string is the presentation text associated with the value.
The value that should be selected by default, if any.
select("language", ({ ({ "eng", "English" }), ({ "swe", "Swedish" }), ({ "nor", "Norwegian" }) }), "swe");
string simple_obox(array(array(string)) rows, void|string frame_color, void|string cell_color, void|string width, void|string padding, void|function(int:string) cell_callback)
This function should solve most of the obox needs that arises. It creates a table out of the array of arrays of strings fed into it. The tables will (with default settings) have a thin black outline around the table and between its cells. Much effort has gone into finding a simple HTML reresentation of such obox that is rendered in a similar way in all popular browsers. The current implementation has been tested against IE, Netscape, Mozilla, Opera and Konquest.
Simply an array of arrays with strings. The strings are the values that should appear in the table cells. All rows should have equal number of cells, otherwise the result will not be very eye pleasing.
The color of the surrounding frame. Defaults to "#000000".
The background color of the cells. Defaults to "#ffffff".
The border width. Defaults to "1".
The amount of padding in each cell. Defaults to "3".
If provided, the cell callback will be called for each cell. As in parameters it will get the current x and y coordinates in the table. The upper left cell is 0,0. In addition to the coordinates it will also receive the background color and the contents of the current cell. It is expected to return a td-element.
function cb = lambda(int x, int y, string bgcolor, string contents) { if(y%2) return "<td bgcolor='#aaaaff'>"+contents+"</td>"; return "<td bgcolor='"+bgcolor+"'>"+contents+"</td>"; } simple_obox(my_rows, "#0000a0", 0, "1", "3", cb);
pad_rows
array(array(string)) pad_rows(array(array(string)) rows, void|string padding)
Pads out the rows in a array of rows to equal length. The new elements in the rows will have the value provided in padding , or " ".
| CLASS String.HTML.OBox |
Provides the same functionality as the simple_obox function, in a "streaming" way. The real gain is different addtition methods as well as the possibility to change the cell callback at any time.
simple_obox
void String.HTML.OBox(void|string frame_color, void|string cell_color, void|string width, void|string padding, void|function(int:string) cell_callback)
void set_cell_callback(function(int:string) cell_callback)
void set_extra_args(mapping(string:string) extra_args)
The argument in the mapping will be added to all created table cells.
void set_extra_args(array(mapping(string:string)) extra_args)
The argument in the mappings will be added to the cell in the cooresponding column of the table.
void add_raw_cell(string cell)
Adds this cell to the table unmodified, e.g. it should have an enclosing td or th element.
void add_tagdata_cell(string tag, mapping(string:string) args, string contents)
Creates a cell from the provided arguments and adds it to the table.
The name of the element that should be produces. Typically "td" or "th".
A mapping with the elements attributes.
The element contents.
void add_cell(string contents)
Adds a cell with the provided content.
void new_row()
Begin a new row. Succeeding cells will be added to this row instead of the current.
void add_row(array(string) cells)
Adds a complete row. If the current row is nonempty a new row will be started.
void pad_rows()
Ensures that all rows have the same number of cells.
string render()
Returns the result.
mixed cast(string to)
It is possible to case this object to a string, which does the same as calling render , and to an array, which returns the cells in an array of rows.
| Module Languages |
| Module Languages.PLIS |
PLIS, Permuted Lisp. A Lisp language somewhat similar to scheme.
void init_specials(Environment environment)
Adds the special functions quote, set!, setq, while, define, defmacro, lambda, if, and, or, begin and catch to the environment .
void init_functions(Environment environment)
Adds the functions +, *, -, =, <, >, concat, read-string, eval, apply, global-environment, var, cdr, null?, setcar!, setcdr!, cons and list to the environment .
Environment default_environment()
Creates a new environment on which it runs init_functions, init_specials and the following boot code.
(begin
(defmacro (cddr x)
(list (quote cdr) (list (quote cdr) x)))
(defmacro (cadr x)
(list (quote car) (list (quote cdr) x)))
(defmacro (cdar x)
(list (quote cdr) (list (quote car) x)))
(defmacro (caar x)
(list (quote car) (list (quote car) x)))
(defmacro (when cond . body)
(list (quote if) cond
(cons (quote begin) body)))
(define (map fun list)
(if (null? list) (quote ())
(cons (fun (car list))
(map fun (cdr list)))))
(defmacro (let decl . body)
(cons (cons (quote lambda)
(cons (map car decl) body))
(map cadr decl))))
void main()
Instantiates a copy of the default environment and starts an interactive main loop that connects to standard I/O. The main loop is as follows:
(begin
(define (loop)
(let ((line (read-line \"PLIS: \")))
(if line
(let ((res (catch (eval (read-string line)
(global-environment)))))
(display res)
(loop)))))
(loop))
| Module ADT |
Various Abstract Data Types.
inherit _ADT : _ADT
| CLASS ADT.Stack |
This class implements a simple stack. Instead of adding and removing elements to an array, and thus making it vary in size for every push and pop operation, this stack tries to keep the stack size constant. If however the stack risks to overflow, it will allocate double its current size, i.e. pushing an element on an full 32 slot stack will result in a 64 slot stack with 33 elements.
void push(mixed val)
Push an element on the top of the stack.
mixed top()
Returns the top element from the stack, without popping it.
Throws an error if called on an empty stack.
void quick_pop(void|int val)
Pops val entries from the stack, or one entry if no value is given. The popped entries are not actually freed, only the stack pointer is moved.
mixed pop(void|int val)
Pops and returns entry val from the stack, counting from the top. If no value is given the top element is popped and returned. All popped entries are freed from the stack.
void reset(int|void initial_size)
Empties the stack, resets the stack pointer and shrinks the stack size to the given value or 32 if none is given.
create
void ADT.Stack(int|void initial_size)
An initial stack size can be given when a stack is cloned. The default value is 32.
void set_stack(array stack)
Sets the stacks content to the provided array.
int _sizeof()
sizeof on a stack returns the number of entries in the stack.
array _values()
values on a stack returns all the entries in the stack, in order.
this_program `+(this_program s)
A stack added with another stack yields a third a third stack will all the stack elements from the two first stacks.
| CLASS ADT.Heap |
This class implements a (min-)heap. The value of a child node will always be greater than or equal to the value of its parent node. Thus, the top node of the heap will always hold the smallest value.
void push(mixed value)
Push an element onto the heap. The heap will automatically sort itself so that the smallest value will be at the top.
void adjust(mixed value)
Takes a value in the heap and sorts it through the heap to maintain its sort criteria (increasing order).
mixed pop()
Removes and returns the item on top of the heap, which also is the smallest value in the heap.
int _sizeof()
Returns the number of elements in the heap.
mixed top()
Removes and returns the item on top of the heap, which also is the smallest value in the heap.
int size()
Returns the number of elements in the heap.
mixed peek()
Returns the item on top of the heap (which is also the smallest value in the heap) without removing it.
| CLASS ADT.struct |
String buffer with the possibility to read and write data as they would be formatted in structs.
void ADT.struct(void|string s)
Create a new buffer, optionally initialized with the value s .
string contents()
Trims the buffer to only contain the data after the read pointer and returns the contents of the buffer.
void add_data(string s)
Adds the data s verbatim to the end of the buffer.
string pop_data()
Return all the data in the buffer and empties it.
void put_uint(int i, int(0..) len)
Appends an unsigned integer in network order to the buffer.
Unsigned integer to append.
Length of integer in bytes.
void put_var_string(string s, int(0..) len_width)
Appends a variable string s preceded with an unsigned integer of the size len_width declaring the length of the string. The string s should be 8 bits wide.
void put_bignum(Gmp.mpz i, int(0..)|void len_width)
Appends a bignum i as a variable string preceded with an unsigned integer of the size len_width declaring the length of the string. len_width defaults to 2.
void put_fix_string(string s)
Appends the fix sized string s to the buffer.
void put_fix_uint_array(array(int) data, int(0..) item_size)
Appends an array of unsigned integers of width item_size to the buffer.
void put_var_uint_array(array(int) data, int(0..) item_size, int(0..) len)
Appends an array of unsigned integers of width item_size to the buffer, preceded with an unsigned integer len declaring the size of the array.
int(0..) get_uint(int len)
Reads an unsigned integer from the buffer.
string get_fix_string(int len)
Reads a fixed sized string of length len from the buffer.
string get_var_string(int len)
Reads a string written by put_var_string from the buffer.
Gmp.mpz get_bignum(int|void len)
Reads a bignum written by put_bignum from the buffer.
string get_rest()
Get the remaining data from the buffer and clears the buffer.
array(int) get_fix_uint_array(int item_size, int size)
Reads an array of integers as written by put_fix_uint_array from the buffer.
array(int) get_var_uint_array(int item_size, int len)
Reads an array of integers as written by put_var_uint_array from the buffer.
int(0..1) is_empty()
Returns one of there is any more data to read.
| CLASS ADT.BitBuffer |
Implements a FIFO bit buffer, i.e. a buffer that operates on bits instead of bytes. It is not designed for performance, but as a way to handle complicated file formats and other standards where you may need to work on unaligned data units of sub byte size, without having to fry your brain while keeping track of all the bits yourself.
> ADT.BitBuffer b=ADT.BitBuffer(); > b->put1(2); (1) Result: ADT.BitBuffer(11) > b->put0(15); (2) Result: ADT.BitBuffer("À\0"0) > b->drain(); (3) Result: "À\0" > sizeof(b); (4) Result: 1
void ADT.BitBuffer(void|string _data)
The buffer can be initialized with initial data during creation.
this_program feed(string x)
Adds full bytes to the buffer.
string drain()
Drains the buffer of all full (8-bits wide) bytes.
int get(int bits)
Get bits from the buffer.
Throws an error in case of data underflow.
string read(void|int bytes)
Reads bytes (or less) bytes from the buffer and returns as string.
this_program put(int value, int bits)
Put bits number of bits with the value value into the buffer.
value must not be larger than what can be stored with the number of bits given in bits .
this_program put0(int bits)
Put bits number of 0 bits into the buffer.
this_program put1(int bits)
Put bits number of 1 bits into the buffer.
int _sizeof()
sizeof() will return the number of bits in the buffer.
| CLASS ADT.Priority_queue |
This class implements a priority queue. Each element in the priority queue is assigned a priority value, and the priority queue always remains sorted in increasing order of the priority values. The top of the priority queue always holds the element with the smallest priority. The priority queue is realized as a (min-)heap.
inherit .Heap : Heap
mixed push(int pri, mixed val)
Push an element val into the priority queue and assign a priority value pri to it. The priority queue will automatically sort itself so that the element with the smallest priority will be at the top.
void adjust_pri(mixed handle, int new_pri)
Adjust the priority value new_pri of an element handle in the priority queue. The priority queue will automatically sort itself so that the element with the smallest priority value will be at the top.
mixed pop()
Removes and returns the item on top of the heap, which also is the smallest value in the heap.
mixed peek()
Returns the item on top of the priority queue (which is also the element with the smallest priority value) without removing it.
| CLASS ADT.Set |
ADT.Set implements a datatype for sets. These sets behave much like multisets, except that they are restricted to containing only one instance of each member value.
From a performance viewpoint, it is probably more efficient for a Pike program to use mappings to serve as sets, rather than using an ADT.Set,so ADT.Set is mainly provided for the sake of completeness and code readability.
void reset()
Remove all items from the set.
void add(mixed ... items)
Add items to the set.
void remove(mixed ... items)
Remove items from the set.
int(0..1) contains(mixed item)
Check whether a value is a member of the set.
int(0..1) is_empty()
Returns 1 if the set is empty, otherwise 0.
array(mixed) map(function f)
Map the values of a set: calls the map function f once for each member of the set, returning an array which contains the result of each one of those function calls. Note that since a set isn't ordered, the values in the returned array will be in more or less random order. If you need to know which member value produced which result, you have to make that a part of what the filtering function returns.
The filtering function f is called with a single, mixed-type argument which is the member value to be mapped.
this_program filter(function f)
Return a filtered version of the set, containing only those members for which the filtering function f returned true.
The filtering function is called with a single mixed-type argument which is the member value to be checked.
this_program filter_destructively(function f)
Destructively filter the set, i.e. remove every element for which the filtering function f returns 0, and then return the set.
The filtering function is called with a single mixed-type argument which is the member value to be checked.
int(0..1) subset(ADT.Set other)
Subset. A <= B returns true if all items in A are also present in B.
int(0..1) superset(ADT.Set other)
Superset. A >= B returns true if all items in B are also present in A.
int(0..1) `==(ADT.Set other)
Equality. A == B returns true if all items in A are present in B, and all items in B are present in A. Otherwise, it returns false.
int(0..1) `<(ADT.Set other)
True subset. A < B returns true if each item in A is also present in B, and B contains at least one item not present in A.
int(0..1) `>(ADT.Set other)
True superset. A > B returns true if each item in B is also present in A, and A contains at least one item not present in B.
function ADT.Set.`<=
Subset operator.
function ADT.Set.`>=
Superset operator.
int(0..1) `!=(ADT.Set other)
Inequality. A != B is equivalent to !(A == B).
this_program `|(ADT.Set other)
Union. Returns a set containing all elements present in either or both of the operand sets.
this_program `&(ADT.Set other)
Intersection. Returns a set containing those values that were present in both the operand sets.
this_program `-(ADT.Set other)
Difference. The expression 'A - B', where A and B are sets, returns all elements in A that are not also present in B.
int(0..1) `[](mixed item)
Indexing a set with a value V gives 1 if V is a member of the set, otherwise 0.
int `[]=(mixed item, int value)
Setting an index V to 0 removes V from the set. Setting it to a non-0 value adds V as a member of the set.
array(mixed) _indices()
In analogy with multisets, indices() of an ADT.Set givess an array containing all members of the set.
array(mixed) _values()
In analogy with multisets, values() of an ADT.Set givess an array indicating the number of occurrences in the set for each position in the member array returned by indices(). (Most of the time, this is probably rather useless for sets, since the result is an array which just contain 1's, one for each member of the set. Still, this function is provided for consistency.
mixed cast(string to)
An ADT.Set can be cast to an array or a multiset.
int _sizeof()
Number of items in the set.
string _sprintf(int t)
Printable representation of the set.
void ADT.Set(void|ADT.Set|array|multiset|mapping initial_data)
Create an ADT.Set, optionally initialized from another ADT.Set or a compatible type. If no initial data is given, the set will start out empty.
| CLASS ADT.History |
A history is a stack where you can only push entries. When the stack has reached a certain size the oldest entries are removed on every push. Other proposed names for this data type is leaking stack and table (where you push objects onto the table in one end and objects are falling off the table in the other.
void ADT.History(int max_size)
max_size is the maximum number of entries that can reside in the history at the same time.
void set_no_adjacent_duplicates(int(0..1) i)
Change how the History object should treat two identical values in a row. If 1 than only unique values are allowed after each other.
query_no_adjacent_duplicates
int(0..1) query_no_adjacent_duplicates()
Tells if the History object allows adjacent equal values. 1 means that only uniqe values are allowed adter each other.
set_no_adjacent_duplicates
void push(mixed value)
Push a new value into the history.
int _sizeof()
A sizeof operation on this object returns the number of elements currently in the history, e.g. <= the current max size.
int get_maxsize()
Returns the maximum number of values in the history
set_maxsize
int get_latest_entry_num()
Returns the absolute sequence number of the latest result inserted into the history.
int get_first_entry_num()
Returns the absolute sequence number of the oldest result still in the history. Returns 0 if there are no results in the history.
mixed `[](int i)
Get a value from the history as if it was an array, e.g. both positive and negative numbers may be used. The positive numbers are however offset with 1, so [1] is the first entry in the history and [-1] is the last.
void `[]=(int i, mixed value)
Overwrite one value in the history. The history position may be identified either by positive or negative offset, like `[] .
void set_maxsize(int _maxsize)
Set the maximume number of entries that can be stored in the history simultaneous.
get_maxsize
void flush()
Empties the history. All entries in the history are removed, to allow garbage collect to remove them. The entry sequence counter is not reset.
array(int) _indices()
Returns the index numbers of the history entries available.
array _values()
Returns the values of the available history entries.
| CLASS ADT.Struct |
Implements a struct which can be used for serialization and deserialization of data.
class ID3 { inherit ADT.Struct; Item head = Chars(3); Item title = Chars(30); Item artist = Chars(30); Item album = Chars(30); Item year = Chars(4); Item comment = Chars(30); Item genre = Byte(); }
Stdio.File f = Stdio.File("foo.mp3"); f->seek(-128); ADT.Struct tag = ID3(f); if(tag->head=="TAG") { write("Title: %s\n", tag->title); tag->title = "A new title" + "\0"*19; f->seek(-128); f->write( (string)tag ); }
class HollerithString { inherit ADT.Struct; Item strlen = Word(); Item str = Chars(strlen); }
void ADT.Struct(void|string|Stdio.File data)
Data to be decoded and populate the struct. Can either be a file object or a string.
void decode(string|Stdio.File data)
Decodes data according to the struct and populates the struct variables. The data can either be a file object or a string.
string encode()
Serializes the struct into a string. This string is equal to the string fed to decode if nothing in the struct has been altered.
mixed `[](string item)
mixed `->(string item)
The struct can be indexed by item name to get the associated value.
mixed `[]=(string item)
mixed `->=(string item)
It is possible to assign a new value to a struct item by indexing it by name and assign a value.
array(string) _indices()
The indices of a struct is the name of the struct items.
array _values()
The values of a struct is the values of the struct items.
int _sizeof()
The size of the struct object is the number of bytes allocated for the struct.
mixed cast(string to)
The struct can be casted into a string, which is eqivivalent to running encode , or into an array. When casted into an array each array element is the encoded value of that struct item.
| CLASS ADT.Struct.Item |
Interface class for struct items.
| CLASS ADT.Struct.Byte |
One byte, integer value between 0 and 255.
inherit Item : Item
void ADT.Struct.Byte(void|int(0..255) initial_value)
The byte can be initialized with an optional value.
| CLASS ADT.Struct.SByte |
One byte, signed integer value between -128 and 127.
inherit Item : Item
void ADT.Struct.SByte(void|int(-128..127) initial_value)
The byte can be initialized with an optional value.
| CLASS ADT.Struct.Word |
One word (2 bytes) in network order, integer value between 0 and 65535.
Drow
inherit Item : Item
void ADT.Struct.Word(void|int(0..65535) initial_value)
The word can be initialized with an optional value.
| CLASS ADT.Struct.SWord |
One word (2 bytes) in network order, signed integer value between 0 and 65535.
inherit Item : Item
void ADT.Struct.SWord(void|int(-32768..32767) initial_value)
The word can be initialized with an optional value.
| CLASS ADT.Struct.Drow |
One word (2 bytes) in intel order, integer value between 0 and 65535.
Word
inherit Word : Word
| CLASS ADT.Struct.Long |
One longword (4 bytes) in network order, integer value between 0 and 2^32.
Gnol
inherit Word : Word
void ADT.Struct.Long(void|int(0..) initial_value)
The longword can be initialized with an optional value.
| CLASS ADT.Struct.SLong |
One longword (4 bytes) in network order, signed integer value -(2^31) <= x < 2^31-1.
inherit SWord : SWord
void ADT.Struct.SLong(void|int initial_value)
The longword can be initialized with an optional value.
| CLASS ADT.Struct.Gnol |
One longword (4 bytes) in intel order, integer value between 0 and 2^32.
Long
inherit Drow : Drow
void ADT.Struct.Gnol(void|int(0..) initial_value)
The longword can be initialized with an optional value.
| CLASS ADT.Struct.Chars |
A string of bytes.
inherit Item : Item
void ADT.Struct.Chars(int|Item size, void|string value)
size is the number of bytes that are part of this struct item, or optionally an earlier Item that will be looked up in runtime. The initial value of the char string is value or, if not provided, a string of zero bytes.
| CLASS ADT.Struct.int8 |
Alias for SByte
inherit SByte : SByte
| CLASS ADT.Struct.uint8 |
Alias for Byte
inherit Byte : Byte
| CLASS ADT.Struct.int16 |
Alias for SWord
inherit SWord : SWord
| CLASS ADT.Struct.uint16 |
Alias for Word
inherit Word : Word
| CLASS ADT.Struct.int32 |
Alias for SLong
inherit SLong : SLong
| CLASS ADT.Struct.uint32 |
Alias for Long
inherit Long : Long
| CLASS ADT.Struct.int64 |
64 bit signed integer.
inherit SLong : SLong
| CLASS ADT.Struct.uint64 |
64 bit unsigned integer.
inherit Long : Long
| CLASS ADT.Queue |
A simple FIFO queue.
void ADT.Queue(mixed ... args)
Creates a queue with the initial items args in it.
void write(mixed item)
void put(mixed item)
Adds the item to the queue.
mixed read()
mixed get()
Returns the next element from the queue.
mixed peek()
Returns the next element from the queue without removing it from the queue.
int(0..1) is_empty()
Returns true if the queue is empty, otherwise zero.
void flush()
Empties the queue.
mixed cast(string to)
It is possible to cast ADT.Queue to an array.
| CLASS ADT.Sequence |
The sequence work similar to an array but has the possibilities to insert and remove elements. It also has a more powerful iterator.
mixed `[](int index)
Index operator.
The index to get the value for, could be negative to index from the end.
The value at the index index .
An error if the index is out of range.
mixed `[]=(int index, mixed value)
Index assign operator. Set the value at the index index to be value .
The index to set.
The new value.
The new value at the index index .
Sequence `+(Sequence ... coll)
Addition operator
Append the content of @coll to this sequence and return the results as a new Sequence .
The sequences to append to this sequence.
The result of the append as a new Sequence .
Sequence `-(Sequence ... coll)
Subtraction operator
Removes those values in this sequence that also are present in @coll and return the results as a new Sequence .
The sequence to subtract from this sequence.
The result of the subtraction as a new Sequence .
Sequence `&(Sequence coll)
And operator Perform an and on this sequence and the coll sequence by only returning those values that is present in both sequences as a new Sequence . The remaining values is in the same order as they are in this sequence and the values are compared using `==.
The sequence to and to this sequence.
The result of the and as a new Sequence .
Sequence `|(Sequence coll)
Or operator Perform an or on this sequence and the coll sequence by returning those values that is present in both sequences as a new Sequence . The values are compared using `==.
The sequence to or with this sequence.
The result of the or as a new Sequence .
Sequence `^(Sequence coll)
Xor operator Perform a xor on this sequence and the coll sequence by returning those values that is present in one of the sequences but not in both adapters as a new Sequence . The values are compared using `==.
The sequence to xor with this sequence.
The result of the xor as a new Sequence .
int(0..1) _equal(mixed coll)
Returns true if the object coll is a Sequence and contains the same values in the same order.
array _indices()
The indices in this adapter as an array.
void _insert_element(int index, mixed value)
Insert an element in the sequence at the position index , the value at the position index and all above will have their index increased by one.
The index to insert the value at.
The new value.
mixed _remove_element(int index)
Remove the values at index index from the sequence.
The index to remove.
The removed value.
int _search(mixed value, void|int start)
Search the sequence for a specific value. Return the index of the first
value that is equal to value . If no value was found UNDEFINED
is returned instead.
The value to find.
If a start value is supplied it will start searching at the index start .
Returns the index of the found value or UNDEFINED.
int _sizeof()
The number of elements in this adapter.
array _values()
The values in this adapter as an array.
void add(mixed value)
Add a value at the end of the sequence.
The value to add.
mixed cast(string type)
Cast operator.
Casts to this type.
Casts to the following types are supported:
|
An array with the contents of this sequence.
void clear()
Clear the contents of the sequence.
int delete_value(mixed value)
Remove the first occurrence of the value value from the sequence.
The value to remove from the sequence.
The index of the removed element or -1 if there was no value to remove.
int(0..1) is_empty()
Returns 1 if the sequence is empty otherwise 0.
int max_size()
Returns -1.
void ADT.Sequence(array|int arg)
Creates a new Sequence around the array arg or a new Sequence with the size of arg.
SequenceIterator _get_iterator(void|int ind)
Create and initiate a new SequenceIterator that could be used to iterate over this sequence.
If an ind value is supplied the iterator will be positioned at that index.
An iterator.
SequenceIterator first()
Create and initiate a new SequenceIterator that could be used to iterate over this sequence.
An iterator positioned at the first element in the sequence.
SequenceIterator last()
Create and initiate a new SequenceIterator that could be used to iterate over this sequence.
An iterator positioned after the last element in the sequence.
| CLASS ADT.Sequence.SequenceIterator |
This is the iterator for the Sequence. It implements the IndexIterator and the OutputIterator
void ADT.Sequence.SequenceIterator(object sequence, void|int start)
Creates a new iterator for the sequence sequence . If start is supplied it will try to position the iterator at start .
int index()
The index at the current position.
mixed value()
The value at the current position.
SequenceIterator `+(int steps)
Move the iterator steps steps forward (negative value on steps will cause the iterator to move backwards) and return the result as a new iterator.
A new iterator positioned steps steps forward.
SequenceIterator `+=(int steps)
Move this iterator steps steps forward (negative value on steps will cause the iterator to move backwards) and return the result.
This iterator positioned steps steps forward.
SequenceIterator `-(int steps)
Move the iterator steps steps backwards (negative value on steps will cause the iterator to move forwards) and return the result as a new iterator.
A new iterator positioned steps steps backwards.
int(0..1) has_next(void|int steps)
Returns true if it is possible to move steps steps forwards, if steps weren't supplied it check if it is possible to move one step forward.
int(0..1) has_previous(void|int steps)
Returns true if it is possible to move steps steps backwards, if steps weren't supplied it check if it is possible to move one step backward.
int(0..1) `!()
Returns false if the iterator has reached the end.
int(0..1) _equal(mixed iter)
Compare this iterator with another iterator.
The iterator to compare with.
Returns true if both iterators iterates over the same objects and are positioned at the same spot.
int(0..1) `<(mixed iter)
Less then operator.
Returns true if this iterator has a lower index then iter .
int(0..1) `>(mixed iter)
Greater then operator.
Returns true if this iterator has a higher index then iter .
int distance(object iter)
The iterator to measure the distance to.
Returns distance between this iterator and iter .
An error if the two iterator could not be compared.
Sequence get_collection()
Returns the Sequence this iterator currently iterates over.
mixed set_value(mixed val)
Set the value at the current position.
The new value.
Returns the old value.
| CLASS ADT.CircularList |
This is an circular list implemented by an array. It has a constant time complexity for pop and push. It has a limited max size but it can be increased with the method allocate.
mixed `[](int index)
Index operator
The index to get the value for, could be negative to index from the end.
The value at the index index
An error if the index is out of range.
mixed `[]=(int index, mixed value)
Index assign operator. Set the value at the index index to be value
The index to set
The new value
The new value at the index index
An error if the index is out of range.
CircularList `+(CircularList ... coll)
Addition operator
Append the content of this CircularList and @coll and return the results as a new CircularList .
The lists to append to this list
The result of the append as a new CircularList .
int(0..1) _equal(mixed coll)
Returns true if the object coll is a CircularList and contains the same values in the same order.
array _indices()
The indices in this list as an array.
void _insert_element(int index, mixed value)
Insert an element in the list at the position index , the value at the position index and all above will have their index increased by one.
The index to insert the value at.
The new value.
An error if the index is out of range.
mixed _remove_element(int index)
Remove the values at index index from the list.
The index to remove.
The removed value.
An error if the index is out of range.
int _search(mixed value, void|int start)
Search the list for a specific value. Return the index of the first
value that is equal to value . If no value was found UNDEFINED
is returned instead
The value to find
If a start value is supplied it will start searching at the index start .
Returns the index of the found value or UNDEFINED.
An error if the start is out of range.
int _sizeof()
The number of elements in this list.
array _values()
The values in this list as an array.
void add(mixed value)
Add a value at the front of the list
The value to add.
An error if the list is full.
void allocate(int elements)
Increase the maxsize of the CircularlList.
Add this number of new elements to the list.
mixed cast(string type)
Cast operator.
Casts to this type.
Casts to the following types are supported:
|
An array with the contents of this list.
void clear()
Clear the contents of the list.
int delete_value(mixed value)
Remove the first occurrence of the value value from the list.
The value to remove from the list.
The index of the removed element or -1 if there was no value to remove.
int(0..1) is_empty()
Returns 1 if the list is empty otherwise 0.
int max_size()
Returns the maximal size of this list.
mixed peek_back()
The value at the back of the list but do not remove it from the list.
mixed peek_front()
The value at the front of the list but do not remove it from the list.
mixed pop_back()
Remove the value at the back of the list and return it.
The value at the back of the list.
mixed pop_front()
Remove the value at the front of the list and return it.
The value at the front of the list.
void push_back(mixed value)
Add a new value at the end of the list.
The value to add.
void push_front(mixed value)
Add a new value at the end of the list.
The value to add.
void ADT.CircularList(array|int arg)
Creates a new CircularList around the array arg or a new CircularList with the maximum size of arg.
CircularListIterator _get_iterator(void|int ind)
Create and initiate a new CircularListIterator that could be used to iterate over this list.
If an ind value is supplied the iterator will be positioned at that index.
An iterator.
CircularListIterator first()
Create and initiate a new CircularListIterator that could be used to iterate over this list.
An iterator positioned at the first element in the list.
CircularListIterator last()
Create and initiate a new CircularListIterator that could be used to iterate over this list.
An iterator positioned after the last element in the list.
| CLASS ADT.CircularList.CircularListIterator |
This is the iterator for the CircularList. It implements the IndexIterator and the OutputIterator.
void ADT.CircularList.CircularListIterator(object list, void|int start)
Creates a new iterator for the CircularList list . If start is supplied it will try to position the iterator at start .
int index()
The index at the current position.
mixed value()
The value at the current position.
CircularListIterator `+(int steps)
Move the iterator steps steps forward (negative value on steps will cause the iterator to move backwards) and return the result as a new iterator.
A new iterator positioned steps steps forward.
CircularListIterator `+=(int steps)
Move this iterator steps steps forward (negative value on steps will cause the iterator to move backwards) and return the result.
This iterator positioned steps steps forward.
CircularListIterator `-(int steps)
Move the iterator steps steps backwards (negative value on steps will cause the iterator to move forwards) and return the result as a new iterator.
A new iterator positioned steps steps backwards.
int(0..1) has_next(void|int steps)
Returns true if it is possible to move steps steps forwards, if steps weren't supplied it check if it is possible to move one step forward.
int(0..1) has_previous(void|int steps)
Returns true if it is possible to move steps steps backwards, if steps weren't supplied it check if it is possible to move one step backward.
int(0..1) `!()
Returns false if the iterator has reached the end.
int(0..1) _equal(mixed iter)
Compare this iterator with another iterator.
The iterator to compare with
Returns true if both iterators iterates over the same objects and are positioned at the same spot.
int(0..1) `<(mixed iter)
Less then operator
Returns true if this iterator has a lower index then iter .
int(0..1) `>(mixed iter)
Greater then operator
Returns true if this iterator has a higher index then iter .
int distance(object iter)
The iterator to measure the distance to.
Returns distance between this iterator and iter .
An error if the two iterator could not be compared.
CircularList get_collection()
Returns the CircularList this iterator currently iterates over.
mixed set_value(mixed val)
Set the value at the current position.
The new value
Returns the old value
| CLASS ADT.List |
Linked list of values.
int(0..1) is_empty()
Check if the list is empty.
Returns 1 if the list is empty,
and 0 (zero) if there are elements in the list.
int(0..) _sizeof()
Returns the number of elements in the list.
string _sprintf(int c, mapping(string:mixed)|void attr)
Describe the list.
sprintf() , lfun::_sprintf()
mixed head()
Get the element at the head of the list.
Throws an error if the list is empty.
is_empty() , tail() , pop()
mixed tail()
Get the element at the tail of the list.
Throws an error if the list is empty.
is_empty() , head() , pop()
mixed pop()
Pop the element at the head of the list from the list.
Throws an error if the list is empty.
is_empty() , head() , tail()
void append(mixed ... values)
Append values to the end of the list.
insert()
void insert(mixed ... values)
Insert values at the front of the list.
append()
void ADT.List(mixed ... values)
Create a new List , and initialize it with values .
Ought to reset the List if called multiple times.
| CLASS ADT.List._get_iterator |
Iterator that loops over the List .
mixed value()
Returns the value at the current position.
int(0..1) first()
Reset the iterator to point to the first element in the list.
Returns 1 if there are elements in the list,
and 0 (zero) if the list is empty.
int(0..1) next()
Advance to the next element in the list.
Returns 1 on success, and 0 (zero)
at the end of the list.
prev()
int(0..1) prev()
Retrace to the previous element in the list.
Returns 1 on success, and 0 (zero)
at the beginning of the list.
next()
Iterator `+=(int steps)
Advance or retrace the specified number of steps .
next() , prev
void insert(mixed val)
Insert val at the current position.
append() , delete() , set()
void append(mixed val)
Append val after the current position.
insert() , delete() , set()
void delete()
Delete the current node.
The current position will advance to the next node. This function thus performes the reverse operation of insert() .
insert() , append() , set()
void set(mixed val)
Set the value of the current position to val .
insert() , append() , delete()
| Module ADT.Relation |
| CLASS ADT.Relation.Binary |
mixed contains(mixed left, mixed right)
Return true/false: does the relation "left R right " exist?
mixed `()(mixed left, mixed right)
Does the same as the contains function: returns true if the relation "left R right " exists, and otherwise false.
this_program add(mixed left, mixed right)
Adds "left R right " as a member of the relation. Returns the same relation.
this_program remove(mixed left, mixed right)
Removes "left R right " as a member of the relation. Returns the same relation.
array map(function f)
Maps every entry in the relation. The function f gets two arguments: the left and the right relation value. Returns an array with the return values of f for each and every mapped entry.
Note: since the entries in the relation are not ordered, the returned array will have its elements in no particular order. If you need to know which relation entry produced which result in the array, you have to make that information part of the value that f returns.
object filter(function f)
Filters the entries in the relation, and returns a relation with all those entries for which the filtering function f returned true. The function f gets two arguments: the left and the right value for every entry in the relation.
this_program filter_destructively(function f)
Filters the entries in the relation destructively, removing all entries for which the filtering function f returns false. The function f gets two arguments: the left and the right value for each entry in the relation.
mixed _sizeof()
Returns the number of relation entries in the relation. (Or with other words: the number of relations in the relation set.)
mixed `<=(object rel)
The expression `rel1 <= rel2' returns true if every relation entry in rel1 is also present in rel2.
mixed `&(mixed rel)
The expression `rel1 & rel2' returns a new relation which has those and only those relation entries that are present in both rel1 and rel2.
mixed `+(mixed rel)
mixed `|(mixed rel)
The expression `rel1 | rel2' and `rel1 + rel2' returns a new relation which has all the relation entries present in rel1, or rel2, or both.
mixed `-(mixed rel)
The expression `rel1 - rel2' returns a new relation which has those and only those relation entries that are present in rel1 and not present in rel2.
this_program make_symmetric()
Makes the relation symmetric, i.e. makes sure that if xRy is part of the relation set, then yRx should also be a part of the relation set.
array find_shortest_path(mixed from, mixed to, void|multiset avoiding)
Assuming the relation's domain and range sets are equal, and that the relation xRy means "there is a path from node x to node y", find_shortest_path attempts to find a path with a minimum number of steps from one given node to another. The path is returned as an array of nodes (including the starting and ending node), or 0 if no path was found. If several equally short paths exist, one of them will be chosen pseudorandomly.
Trying to find a path from a node to itself will always succeed, returning an array of one element: the node itself. (Or in other words, a path with no steps, only a starting/ending point).
The argument avoiding is either 0 (or omitted), or a multiset of nodes that must not be part of the path.
mixed get_id()
Return the ID value which was given as first argument to create().
| CLASS ADT.Relation.Binary._get_iterator |
An iterator which makes all the left/right entities in the relation available as index/value pairs.
| Module ADT.Table |
ADT.Table is a generic module for manipulating tables.
Each table contains one or several columns. Each column is associated with a name, the column name. Optionally, one can provide a column type. The Table module can do a number of operations on a given table, like computing the sum of a column, grouping, sorting etc.
All column references are case insensitive. A column can be referred to by its position (starting from zero). All operations are non-destructive. That means that a new table object will be returned after, for example, a sort.
| CLASS ADT.Table.table |
The table base-class.
string encode()
This method returns a binary string representation of the table. It is useful when one wants to store a the table, for example in a file.
object decode(string s)
This method returns a table object from a binary string representation of a table, as returned by encode() .
array(string) _indices()
This method returns the column names for the table. The case used when the table was created will be returned.
array(array) _values()
This method returns the contents of a table as a two dimensional array. The format is an array of rows. Each row is an array of columns.
int _sizeof()
This method returns the number of rows in the table.
object reverse()
This method reverses the rows of the table and returns a new table object.
array col(int|string column)
This method returns the contents of a given column as an array.
array row(int row_number)
This method returns the contents of a given row as an array.
array `[](int|string column)
Same as col() .
int `==(object table)
This method compares two tables. They are equal if the contents of the tables and the column names are equal. The column name comparison is case insensitive.
object append_bottom(object table)
This method appends two tables. The table given as an argument will be added at the bottom of the current table. Note, the column names must be equal. The column name comparison is case insensitive.
object append_right(object table)
This method appends two tables. The table given as an argument will be added on the right side of the current table. Note that the number of rows in both tables must be equal.
object select(int|string ... columns)
This method returns a new table object with the selected columns only.
object remove(int|string ... columns)
Like select() , but the given columns will not be in the resulting table.
object where(array(int|string)|int|string columns, function f, mixed ... args)
This method calls the function for each row. If the function returns zero, the row will be thrown away. If the function returns something non-zero, the row will be kept. The result will be returned as a new table object.
this_program group(mapping(int|string:function)|function f, mixed ... args)
This method calls the function f for each column each time a non uniqe row will be joined. The table will be grouped by the columns not listed. The result will be returned as a new table object.
this_program sum(int|string ... columns)
This method sums all equal rows. The table will be grouped by the columns not listed. The result will be returned as a new table object.
this_program distinct(int|string ... columns)
This method groups by the given columns and returns a table with only unique rows. When no columns are given, all rows will be unique. A new table object will be returned.
object map(function f, array(int|string)|int|string columns, mixed ... args)
This method calls the function f for all rows in the table. The value returned will replace the values in the columns given as argument to map. If the function returns an array, several columns will be replaced. Otherwise the first column will be replaced. The result will be returned as a new table object.
object sort(int|string ... columns)
This method sorts the table in ascendent order on one or several columns and returns a new table object. The left most column is sorted last. Note that the sort is stable.
rsort()
object rsort(int|string ... columns)
Like sort() , but in descending order.
object limit(int n)
This method truncates the table to the first n rows and returns a new object.
object rename(string|int from, string to)
This method renames the column named from to to and returns a new table object. Note that from can be the column position.
mapping type(int|string column, void|mapping type)
This method gives the type for the given column .
If a second argument is given, the old type will be replaced with type . The column type is only used when the table is displayed. The format is as specified in create() .
void ADT.Table.table(array(array) table, array(string) column_names, array(mapping(string:string))|void column_types)
The ADT.Table.table class takes two or three arguments:
The first argument is a two-dimensional array consisting of one array of columns per row. All rows must have the same number of columns as specified in column_names .
This argument is an array of column names associated with each column in the table. References by column name are case insensitive. The case used in column_names will be used when the table is displayed. A column can also be referred to by its position, starting from zero.
This is an optional array of mappings. The column type
information is only used when displaying the table. Currently, only the
keyword "type" is recognized. The type can be specified as
"text" or "num" (numerical). Text columns are left
adjusted, whereas numerical columns are right adjusted. If a mapping
in the array is 0 (zero), it will be assumed to be a text column.
If column_types is omitted, all columns will displayed as text.
See ADT.Table.ASCII.encode() on how to display a table.
ADT.Table.ASCII.encode()
| Module ADT.Table.ASCII |
string encode(object table, void|mapping options)
This method returns a table represented in ASCII suitable for
human eyes. options is an optional mapping. If the keyword
"indent" is used with a number, the table will be
indented with that number of space characters.
| Module Geography |
| CLASS Geography.Position |
This class contains a geographical position, ie a point on the earths surface. The resulting position object implements comparision methods (__hash, `==, `< and `>) so that you can compare and sort positions as well as using them as index in mappings. Comparision is made primary on latidue and secondly on longitude. It does not currently take the ellipsoid into account.
It is possible to cast a position into an array, which will yield ({ float latitude, float longitude }), as well as into a string.
float Geography.Position.lat
Latitude (N--S) of the position, in degrees. Positive number is north, negative number is south.
float Geography.Position.long
Longitude (W--E) of the position, in degrees. Positive number is east, negative number is west.
float Geography.Position.alt
Altitud of the position, in meters. Positive numbers is up. Zero is the shell of the current ellipsoid.
void Geography.Position(float lat, float long, void|float alt)
void Geography.Position(string lat, string long)
void Geography.Position(string both)
Constructor for this class. If fed with strings, it will perform a dwim scan on the strings. If they fails to be understood, there will be an exception.
string latitude(void|int n)
string longitude(void|int n)
Returns the nicely formatted latitude or longitude.
|
string standard_grid()
Returns the standard map grid system for the current position. Can either be "UPS" or "UTM".
float Geography.Position.polar_radius
The polar radius is how many meters the earth radius is at the poles (north-south direction).
float Geography.Position.equatorial_radius
The equatorial radius is how many meters the earth radius is at the equator (east-west direction).
float flattening()
Returns the flattening factor for the selected earth approximation ellipsoid.
float eccentricity_squared()
Returns the first eccentricity squared for the selected earth approximation ellipsoid.
constant Geography.Position.ellipsoids
A mapping with reference ellipsoids, which can be fed to the UTM converter. The mapping maps the name of the ellipsoid to an array where the first element is a float describing the equatorial radius and the second element is a float describing the polar radius.
int(0..1) set_ellipsoid(string name)
int(0..1) set_ellipsoid(float equatorial_radius, float polar_radius)
Sets the equatorial and polar radius to the provided values. A name can also be provided, in which case the radius will be looked up in the ellipsoid mapping. The function returns 1 upon success, 0 on failure.
|
The longitude and lattitude are not converted to the new ellipsoid.
int UTM_zone_number()
Returns the UTM zone number for the current longitude, with correction for the Svalbard deviations.
string UTM_zone_designator()
Returns the UTM letter designator for the current latitude. Returns "Z" if latitude is outside the UTM limits of 84N to 80S.
array(float) UTM_offset()
Returns the offset within the present UTM cell. The result will be returned in an array of floats, containing easting and northing.
string UTM()
Returns the current UTM coordinates position. An example output is "32T 442063.562 5247479.500" where the parts are zone number + zone designator, easting and northing.
void set_from_UTM(int zone_number, string zone_designator, float UTME, float UTMN)
Sets the longitude and lattitude from the given UTM coordinates.
string GEOREF()
Gives the full GEOREF position for the current position, e.g. "LDJA0511".
array(float) RT38()
void set_from_RT38(int|float|string x_n, int|float|string y_e)
Sets the longitude and lattitude from the given RT38 coordinates.
float approx_height()
Returns a very crude approximation of where the ground level is at the current position, compared against the ellipsoid shell. WGS-84 is assumed, but the approximation is so bad that it doesn't matter which of the standard ellipsoids is used.
array(float) ECEF()
Returns the current position as Earth Centered Earth Fixed Cartesian Coordinates.
({ X, Y, Z })
int __hash()
int `==(object pos)
int `<(object pos)
int `>(object pos)
string _sprintf(int|void t)
float euclidian_distance(this_program p)
Calculate the euclidian distance between two Geography.Position. Result is in meter. This uses the ECEF function.
| CLASS Geography.PositionRT38 |
Create a Position object from a RT38 coordinate
inherit .Position : Position
| Module Geography.Countries |
array(Country) Geography.Countries.countries
All known countries.
Country from_domain(string domain)
Look up a country from a domain name. Returns zero if the domain doesn't map to a country. Note that there are some valid domains that don't:
International
US Military
Network
Non-Profit Organization
Old style Arpanet
Nato field
And that US has five domains, Great Britain and france two: <dl compact> <dt>EDU <dd>US Educational <dt>MIL <dd>US Military <dt>GOV <dd>US Government <dt>UM <dd>US Minor Outlying Islands <dt>US <dd>US <dt>GB <dd>Great Britain (UK) <dt>UK <dd>United Kingdom <dt>FR <dd>France <dt>FX <dd>France, Metropolitan <dt>There's also three domains that for convinience maps to US: <dt>NET <dd>Network <dt>ORG <dd>Organization <dt>COM <dd>Commercial </dl>
Country from_domain(string name)
Look up a country from its name or aka. The search is case-insensitive but regards whitespace and interpunctation.
mapping(string:array(Country)) continents()
Gives back a mapping from continent name to an array of the countries on that continent.
The continents are:
"Europe"
"Africa"
"Asia"
"North America"
"South America"
"Oceania"
"Antarctica"
Some countries are considered to be on more than one continent.
mixed `[](string what)
mixed `->(string what)
Convenience functions for getting a country the name-space way; it looks up whatever it is in the name- and domain-space and returns that country if possible:
> Geography.Countries.se;
Result: Country(Sweden)
> Geography.Countries.djibouti;
Result: Country(Djibouti)
> Geography.Countries.com;
Result: Country(United States)
> Geography.Countries.wallis_and_futuna_islands->iso2;
Result: "WF"
| CLASS Geography.Countries.Country |
Country
string Geography.Countries.Country.iso2
ISO 2-character code aka domain name
string Geography.Countries.Country.fips10
FIPS 10-character code; "Federal Information Processing Standards 10-3" etc, used by some goverments in the US.
string Geography.Countries.Country.name
array(string) Geography.Countries.Country.aka
Country name and as-known-as, if any
int Geography.Countries.Country.former
Flag that is set if this country doesn't exist anymore. (eg USSR.)
string continent()
Returns the continent of the country.
Some countries are geographically in more then one continent; any of the continents might be returned then, but probably the continent in which the capital is resident - Europe for Russia, for instance.
string cast("string")
It is possible to cast a country to a string,
which will be the same as performing
country->name;.
| Module Pike |
constant Pike.WEAK_INDICES
constant Pike.WEAK_VALUES
constant Pike.WEAK
Flags for use together with set_weak_flag and get_weak_flag . See set_weak_flag for details.
constant Pike.INDEX_FROM_BEG
constant Pike.INDEX_FROM_END
constant Pike.OPEN_BOUND
Used with predef::`[..] and lfun::`[..] to specify how the corresponding index maps to an upper or lower range bound:
The index is relative to the beginning of the string or array (or any other sequence implemented through an object). Sequences typically start at zero.
The index is relative to the end of the sequence. In strings and arrays, the last element is at zero, the one before that at one, etc.
The range is open in the corresponding direction. The index is irrelevant in this case.
constant Pike.Backend
The class of the DefaultBackend .
Typically something that has inherited __Backend .
__Backend , DefaultBackend
program Pike.SmallBackend
This is the most suitable backend implementation if you only want to monitor a small number of Stdio.File objects.
mapping(string:int|string) get_runtime_info()
Get information about the Pike runtime.
Returns a mapping with the following content:
|
mapping(string:float) gc_parameters(void|mapping(string:mixed) params)
Set and get various parameters that control the operation of the garbage collector. The passed mapping contains the parameters to set. If a parameter is missing from the mapping, the current value will be filled in instead. The same mapping is returned. Thus an empty mapping, or no argument at all, causes a mapping with all current settings to be returned.
The following parameters are recognized:
|
gc , Debug.gc_status
int count_memory(int|mapping(string:int) options, array|multiset|mapping|object|program|string|type(mixed)|int ... things)
In brief, if you call Pike.count_memory(0,x) you get back
the number of bytes x occupies in memory.
The detailed story is a bit longer:
This function calculates the number of bytes that all things occupy. Or put another way, it calculates the number of bytes that would be freed if all those things would lose their references at the same time, i.e. not only the memory in the things themselves, but also in all the things that are directly and indirectly referenced from those things and not from anywhere else.
The memory counted is only that which is directly occupied by the things in question, including any overallocation for mappings, multisets and arrays. Other memory overhead that they give rise to is not counted. This means that if you would count the memory occupied by all the pike accessible things you would get a figure significantly lower than what the OS gives for the pike process.
Also, if you were to actually free the things, you should not expect the size of the pike process to drop the amount of bytes returned by this function. That since Pike often retains the memory to be reused later.
However, what you should expect is that if you actually free the things and then later allocates some more things for which this function returns the same size, there should be essentially no increase in the size of the pike process (some increase might occur due to internal fragmentation and memory pooling, but it should be small in general and over time).
The search for things only referenced from things can handle limited cyclic structures. That is done by doing a "lookahead", i.e. searching through referenced things that apparently have other outside references. You can control how long this lookahead should be through options (see below). If the lookahead is too short to cover the cycles in a structure then a too low value is returned. If the lookahead is made gradually longer then the returned value will eventually become accurate and not increase anymore. If the lookahead is too long then unnecessary time might be spent searching through things that really have external references.
Objects that are known to be part of cyclic structures are
encouraged to have an integer constant or variable
pike_cycle_depth that specifies the lookahead needed to
discover those cycles. When Pike.count_memory visits such
objects, it uses that as the lookahead when going through the
references emanating from them. Thus, assuming objects adhere to
this convention, you should rarely have to specify a lookahead
higher than zero to this function.
Note that pike_cycle_depth can also be set to zero to
effectively stop the lookahead from continuing through the object.
That can be useful to put in objects you know have global
references, to speed up the traversal.
If this is an integer, it specifies the maximum lookahead
distance. -1 counts only the memory of the given things ,
without following any references. 0 extends the count to all
their referenced things as long as there are no cycles (except
if pike_cycle_depth is found in objects - see above). 1
makes it cover cycles of length 1 (e.g. a thing points to
itself), 2 handles cycles of length 2 (e.g. where two things
point at each other), and so on.
However, the lookahead is by default blocked by programs, i.e. it never follows references emanating from programs. That since programs seldom are part of dynamic data structures, and they also typically contain numerous references to global data which would add a lot of work to the lookahead search.
To control the search in more detail, options can be a mapping instead:
|
When the collect_stats flag is set, the mapping is
extended with these elements:
|
One or more things to count memory size for. Only things passed by reference are allowed, except for functions which are forbidden because a meaningful size calculation can't be done for them.
Integers are allowed because they are bignum objects when they become sufficiently large. However, passing an integer that is small enough to fit into the native integer type will return zero.
Returns the number of bytes occupied by the counted things. If
the return_count option is set then the number of things
are returned instead.
The result of Pike.count_memory(0,a,b) might be larger
than the sum of Pike.count_memory(0,a) and
Pike.count_memory(0,b) since a and b
together might reference things that aren't referenced from
anywhere else.
It's possible that a string that is referenced still isn't counted, because strings are always shared in Pike and the same string might be in use in some unrelated part of the program.
| CLASS Pike.__Backend |
Base class for the various backend implementations.
Implements callback registration functions and defines the main backend APIs.
function(Backend:void) Pike.__Backend.before_callback
function(Backend:void) Pike.__Backend.after_callback
If set, these are called just before and after the backend waits for an event.
If an error is thrown from these callbacks then it is reported
using master()->handle_error() - it doesn't interrupt
the operation of the backend.
mixed call_out(function f, float|int delay, mixed ... args)
Make a delayed call to a function.
call_out() places a call to the function f with the argument args in a queue to be called in about delay seconds.
If f returns -1, no other call out or callback will be
called by the backend in this round. I.e. `() will return right
away. For the main backend that means it will immediately start
another round and check files and call outs anew.
Returns a call_out identifier that identifies this call_out. This value can be sent to eg find_call_out() or remove_call_out() .
remove_call_out() , find_call_out() , call_out_info()
int _do_call_outs()
Do all pending call_outs.
This function runs all pending call_outs that should have been run if Pike returned to the backend. It should not be used in normal operation.
As a side-effect, this function sets the value returned by time(1) to the current time.
Zero if no call outs were called, nonzero otherwise.
call_out() , find_call_out() , remove_call_out()
int find_call_out(function f)
int find_call_out(mixed id)
Find a call out in the queue.
This function searches the call out queue. If given a function as argument, it looks for the first call out scheduled to that function.
The argument can also be a call out id as returned by call_out() , in which case that call_out will be found (Unless it has already been called).
find_call_out() returns the remaining time in seconds before that call_out will be executed. If no call_out is found, zero_type (find_call_out (f)) will return 1.
call_out() , remove_call_out() , call_out_info()
int remove_call_out(function f)
int remove_call_out(int id)
Remove a call out from the call out queue.
This function finds the first call to the function f in the call_out queue and removes it. You can also give a call out id as argument (as returned by call_out() or find_call_out() ).
The remaining time in seconds left to that call out will be returned. If no call_out was found, zero_type (remove_call_out (f )) will return 1.
call_out_info() , call_out() , find_call_out()
array(array) call_out_info()
Get info about all call_outs.
This function returns an array with one entry for each entry in the call out queue. The first in the queue will be at index 0. Each index contains an array that looks like this:
| ||||||||||
call_out() , find_call_out() , remove_call_out()
float|int(0..0) `()(void|float|int(0..0) sleep_time)
Perform one pass through the backend.
Calls any outstanding call-outs and non-blocking I/O callbacks that are registred in this backend object.
Wait at most sleep_time seconds. The default when
unspecified or the integer 0 is no time limit.
If the backend did call any callbacks or call outs then the
time spent in the backend is returned as a float. Otherwise
the integer 0 is returned.
Pike.DefaultBackend , main()
Thread.Thread executing_thread()
int executing_thread()
Return the thread currently executing in the backend. I.e. the thread that has called `() and haven't exited from that call. Zero is returned if there's no thread in the backend.
If Pike is compiled without thread support then 1 is
returned if we're inside the backend, 0 otherwise.
void add_file(Stdio.File|Stdio.FILE f)
Register a file to be handled by this backend.
File to register.
Registers f to be handled by this backend.
This simply does f->set_backend(backend) where
backend is this object.
Pike.DefaultBackend , main()
int id()
Return an integer that uniquely identifies this backend. For
the default backend that integer is 0.
| CLASS Pike.PollDeviceBackend |
Backend implemented with /dev/poll (Solaris, OSF/1 and IRIX), epoll(2) (Linux) or kqueue(2) (MacOS X, FreeBSD, OpenBSD, etc).
Backend
inherit __Backend : __Backend
float|int(0..0) `()(void|float|int(0..0) sleep_time)
Perform one pass through the backend.
Calls any outstanding call-outs and non-blocking I/O callbacks that are registred in this backend object.
Wait at most sleep_time seconds. The default when
unspecified or the integer 0 is no time limit.
If the backend did call any callbacks or call outs then the
time spent in the backend is returned as a float. Otherwise
the integer 0 is returned.
Pike.DefaultBackend , main()
| CLASS Pike.PollBackend |
Backend implemented with poll(2) (SVr4, POSIX).
Backend
inherit __Backend : __Backend
float|int(0..0) `()(void|float|int(0..0) sleep_time)
Perform one pass through the backend.
Calls any outstanding call-outs and non-blocking I/O callbacks that are registred in this backend object.
Wait at most sleep_time seconds. The default when
unspecified or the integer 0 is no time limit.
If the backend did call any callbacks or call outs then the
time spent in the backend is returned as a float. Otherwise
the integer 0 is returned.
Pike.DefaultBackend , main()
| CLASS Pike.SelectBackend |
Backend based on the classic select(2) system call from BSD.
inherit __Backend : __Backend
float|int(0..0) `()(void|float|int(0..0) sleep_time)
Perform one pass through the backend.
Calls any outstanding call-outs and non-blocking I/O callbacks that are registred in this backend object.
Wait at most sleep_time seconds. The default when
unspecified or the integer 0 is no time limit.
If the backend did call any callbacks or call outs then the
time spent in the backend is returned as a float. Otherwise
the integer 0 is returned.
Pike.DefaultBackend , main()
| CLASS Pike.BacktraceFrame |
int(0..1) _is_type(string t)
This object claims to be an array for backward compatibility.
string _sprintf(int c, mapping|void opts)
int(3..) _sizeof()
mixed `[](int index, int|void end_or_none)
The BacktraceFrame object can be indexed as an array.
mixed `[]=(int index, mixed value)
| CLASS Pike.Encoder |
Codec for use with encode_value . It understands all the standard references to builtin functions, pike modules, and the main program script.
The format of the produced identifiers are documented here to allow extension of this class:
The produced names are either strings or arrays. The string variant specifies the thing to look up according to the first character:
'c' Look up in all_constants(). 's' Look up in _static_modules. 'r' Look up with resolv(). 'p' Look up in programs. 'o' Look up in programs, then look up the result in objects. 'f' Look up in fc.
In the array format, the first element is a string as above and the rest specify a series of things to do with the result:
A string Look up this string in the result. 'm' Get module object in dirnode. 'p' Do object_program(result).
All lowercase letters and the symbols ':', '/' and '.' are reserved for internal use in both cases where characters are used above.
string|array nameof(mixed what, void|array(object) module_object)
When module_object is set and the name would end with an
object_program step (i.e. 'p'), then drop that
step so that the name corresponds to the object instead.
module_object [0] will receive the found object.
void Pike.Encoder(void|mixed encoded)
Creates an encoder instance. If encoded is specified, it's encoded instead of being reverse resolved to a name. That's necessary to encode programs.
| CLASS Pike.Decoder |
Codec for use with decode_value . This is the decoder corresponding to Encoder . See that one for more details.
void|string Pike.Decoder.fname
void|int Pike.Decoder.mkobj
void|object Pike.Decoder.handlervoid Pike.Decoder(void|string fname, void|int mkobj, void|object handler)
array(mixed) decode_object(object o, mixed data)
Restore the state of an encoded object.
Object to modify.
State information from Encoder()->encode_object() .
The default implementation calls o->_decode(data)
if the object has an _decode(), otherwise if
data is an array, returns it to indicate that lfun::create()
should be called.
This function is called beforelfun::create() in the object has been called, but after lfun::__INIT() has been called.
Returns an array to indicate to the caller that lfun::create() should be called with the elements of the array as arguments.
Returns 0 (zero) to inhibit calling of lfun::create() .
Encoder()->encode_object()
| CLASS Pike.Codec |
Encoder and Decoder rolled into one. This is for mainly compatibility; there's typically no use combining encoding and decoding into the same object.
inherit Encoder : Encoder
inherit Decoder : Decoder
void Pike.Codec(void|mixed encoded)
The optional argument is the thing to encode; it's passed on to Encoder .
| Module Pike.Security |
Pike has an optional internal security system, which can be enabled with the configure-option --with-security.
The security system is based on attaching credential objects (Pike.Security.Creds ) to objects, programs, arrays, mappings or multisets.
A credential object in essence holds three values:
user -- The owner.
allow_bits -- Run-time access permissions.
data_bits -- Data access permissions.
mixed call_with_creds(Creds creds, mixed func, mixed ... args)
Call with credentials.
Sets the current credentials to creds , and calls
func (@args ). If creds is 0 (zero), the
credentials from the current object will be used.
The current creds or the current object must have the allow bit
BIT_SECURITY set to allow calling with creds other than
0 (zero).
Creds get_current_creds()
Get the current credentials
Returns the credentials that are currently active.
Returns 0 (zero) if no credentials are active.
call_with_creds()
Creds get_object_creds(object|program|function|array|mapping|multiset o)
Get the credentials from o .
Returns 0 if o does not have any credentials.
constant Pike.Security.BIT_INDEX
Allow indexing.
constant Pike.Security.BIT_SET_INDEX
Allow setting of indices.
constant Pike.Security.BIT_CALL
Allow calling of functions.
constant Pike.Security.BIT_SECURITY
Allow usage of security related functions.
constant Pike.Security.BIT_NOT_SETUID
Don't change active credentials on function call.
constant Pike.Security.BIT_CONDITIONAL_IO
Allow conditional useage of I/O. The callbacks valid_open
and valid_io will be called in the User object in the
current Creds object to determine if the I/O is allowed or not.
constant Pike.Security.BIT_DESTRUCT
Allow use of destruct .
| CLASS Pike.Security.User |
Virtual class for User objects, used in Creds objects.
int(0..3)|string valid_open(string type, object current, string filename, string flags, int access)
This callback gets called when a new file is to be opened (and the Creds object has BIT_CONDITIONAL_IO set).
The type of file operation requested. Can either be "read"
or "write".
The current object, i.e. the Fd object the user is trying to open.
The file name requested.
The flag string passed to open, e.g. "cwt".
The access flags requested for the file, e.g. 0666.
The function can either return a string, which means that the user is allowed to open a file, but the returned file should be opened instead, or it can return an integer. The integers are intepreted as follows.
|
int(0..3)|array valid_io(string fun, string type, mixed ... args)
This callback gets called when I/O operations not performed on file objects are performed.
| CLASS Pike.Security.Creds |
The credentials object.
Creds get_default_creds()
Get the default credentials.
Returns the default credentials object if it has been set.
Returns 0 (zero) if it has not been set.
set_default_creds()
void set_default_creds(Creds creds)
Set the default credentials
The current creds must have the allow bit BIT_SECURITY set.
get_default_creds()
void Pike.Security.Creds(User user, int allow_bits, int data_bits)
Initialize a new credentials object.
Any of the flags BIT_SECURITY and BIT_CONDITIONAL_IO or:ed together.
Any of the flags BIT_INDEX , BIT_SET_INDEX , BIT_CALL , BIT_NOT_SETUID and BIT_DESTRUCT or:ed together.
Throws an exception if the current creds doesn't have the allow bit BIT_SECURITY set.
object get_user()
Get the user part.
int get_allow_bits()
Get the allow_bit bitmask.
int get_data_bits()
Get the data_bits bitmask.
void apply(object|program|function|array|mapping|multiset o)
Set the credentials for o to this credentials object.
To perform this operation the current credentials needs to have the bit BIT_SECURITY set, or have the same user as the old credentials and not change the user by performing the operation.
| Module Pike.DefaultBackend |
This is the Backend object that files and call_outs are handled by by default.
This is also the Backend object that will be used if main()
returns -1.
Backend , Stdio.File()->set_nonblocking() , call_out()
| Module Protocols |
| Module Protocols.LysKOM |
| CLASS Protocols.LysKOM.Connection |
This class contains nice abstraction for calls into the server. They are named "call", "async_call" or "async_cb_call", depending on how you want the call to be done.
mixed XXX(mixed ... args)
object async_XXX(mixed ... args)
object async_cb_XXX(function callback, mixed ... args)
Do a call to the server. This really clones a Protocols.LysKOM.Request object, and initialises it. XXX is to be read as one of the calls in the lyskom protocol. ('-' is replaced with '_'.) (ie, logout, async_login or async_cb_get_conf_stat.)
The first method is a synchronous call. This will send the command, wait for the server to execute it, and then return the result.
The last two are asynchronous calls, returning an initialised Protocols.LysKOM.Request object.
int Protocols.LysKOM.Connection.protocol_level
string Protocols.LysKOM.Connection.session_software
string Protocols.LysKOM.Connection.software_version
Description of the connected server.
void Protocols.LysKOM.Connection(string server)
void Protocols.LysKOM.Connection(string server, mapping options)
The options argument is a mapping with the following members:
|
| CLASS Protocols.LysKOM.Session |
object Protocols.LysKOM.Session.user
This variable contains the Protocols.LysKOM.Session.Person that is logged in.
void Protocols.LysKOM.Session(string server)
void Protocols.LysKOM.Session(string server, mapping options)
Initializes the session object, and opens a connection to that server.
options is a mapping of options:
|
Connection
Text text(int no)
Returns the text no .
Person person(int no)
Returns the Person no .
Conference conference(int no)
Returns conference number no .
array(ProtocolTypes.ConfZInfo) try_complete_person(string orig)
Runs a LysKOM completion on the given string, returning an array of confzinfos of the match.
object login(int user_no, string password)
object login(int user_no, string password, int invisible)
Performs a login. Throws a lyskom error if unsuccessful.
The session object logged in.
object create_person(string name, string password)
Create a person, which will be logged in. returns the new person object
this_program logout()
Logouts from the server. returns the called object
object create_text(string subject, string body, mapping options)
object create_text(string subject, string body, mapping options, function callback, mixed ... extra)
Creates a new text.
if callback is given, the function will be called when the text has been created, with the text as first argument. Otherwise, the new text is returned.
options is a mapping that may contain:
|
The items above marked with '*' are only available on protocol 10 servers. A LysKOM error will be thrown if the call fails.
Conference.create_text() , Text.comment() , Text.footnote()
object|void send_message(string textstring, mapping options)
Sends a message.
options is a mapping that may contain:
|
void register_async_message_callback(function(int:void) cb)
| CLASS Protocols.LysKOM.Session.AuxItemInput |
Undocumented
inherit ProtocolTypes.AuxItemInput : AuxItemInput
| CLASS Protocols.LysKOM.Session.AuxItems |
Undocumented
| CLASS Protocols.LysKOM.Session.Text |
All variables in this class is read only.
Undocumented
int Protocols.LysKOM.Session.Text.no
The text number, as spicified to create .
object Protocols.LysKOM.Session.Text.err
Undocumented
void Protocols.LysKOM.Session.Text(string textnumber)
Initializes a Text object.
void mark_as_read()
Undocumented.
mixed Protocols.LysKOM.Session.Text.prefetch_text
mixed Protocols.LysKOM.Session.Text.prefetch_stat
mixed Protocols.LysKOM.Session.Text.lines
mixed Protocols.LysKOM.Session.Text.characters
mixed Protocols.LysKOM.Session.Text.clear_stat
mixed Protocols.LysKOM.Session.Text.aux_items
Undocumented
string Protocols.LysKOM.Session.Text.text
The actual text (or body if you wish).
string Protocols.LysKOM.Session.Text.subject
The message subject.
string Protocols.LysKOM.Session.Text.author
The author of the text.
mixed Protocols.LysKOM.Session.Text.misc
Misc info, including what conferences the message is posted to.
Needs a more complete description.
int Protocols.LysKOM.Session.Text.marks
The number of marks on this text.
mixed Protocols.LysKOM.Session.Text.creation_time
The time the text was created on the server.
| CLASS Protocols.LysKOM.Session.Membership |
All variables in this class is read only.
object Protocols.LysKOM.Session.Membership.last_time_read
int(0..255) Protocols.LysKOM.Session.Membership.priority
int Protocols.LysKOM.Session.Membership.last_text_read
array(int) Protocols.LysKOM.Session.Membership.read_texts
object Protocols.LysKOM.Session.Membership.added_at
multiset(string) Protocols.LysKOM.Session.Membership.type
int Protocols.LysKOM.Session.Membership.position
object Protocols.LysKOM.Session.Membership.conf
int number_unread()
void query_read_texts()
array(object) unread_texts()
| CLASS Protocols.LysKOM.Session.Person |
int Protocols.LysKOM.Session.Person.no
void Protocols.LysKOM.Session.Person(int no)
mixed Protocols.LysKOM.Session.Person.prefetch_stat
mixed Protocols.LysKOM.Session.Person.prefetch_conf
mixed Protocols.LysKOM.Session.Person.prefetch_membership
Undocumented
object Protocols.LysKOM.Session.Person.error
Text Protocols.LysKOM.Session.Person.user_area
mixed Protocols.LysKOM.Session.Person.username
mixed Protocols.LysKOM.Session.Person.privileges
mixed Protocols.LysKOM.Session.Person.flags
mixed Protocols.LysKOM.Session.Person.last_login
mixed Protocols.LysKOM.Session.Person.total_time_present
mixed Protocols.LysKOM.Session.Person.sessions
mixed Protocols.LysKOM.Session.Person.created_lines
mixed Protocols.LysKOM.Session.Person.created_bytes
mixed Protocols.LysKOM.Session.Person.read_texts
mixed Protocols.LysKOM.Session.Person.no_of_text_fetches
mixed Protocols.LysKOM.Session.Person.created_persons
mixed Protocols.LysKOM.Session.Person.created_confs
mixed Protocols.LysKOM.Session.Person.first_created_local_no
mixed Protocols.LysKOM.Session.Person.no_of_created_texts
mixed Protocols.LysKOM.Session.Person.no_of_marks
mixed Protocols.LysKOM.Session.Person.no_of_confs
mixed Protocols.LysKOM.Session.Person.unread
int(0..0) Protocols.LysKOM.Session.Person.clear_membership
mixed Protocols.LysKOM.Session.Person.membership
Undocumented
| CLASS Protocols.LysKOM.Session.Conference |
void Protocols.LysKOM.Session.Conference(int no)
mixed Protocols.LysKOM.Session.Conference.prefetch_stat
int Protocols.LysKOM.Session.Conference.no
object Protocols.LysKOM.Session.Conference.error
Text Protocols.LysKOM.Session.Conference.msg_of_day
Conference Protocols.LysKOM.Session.Conference.supervisor
Conference Protocols.LysKOM.Session.Conference.permitted_submitters
Conference Protocols.LysKOM.Session.Conference.super_conf
Person Protocols.LysKOM.Session.Conference.creator
mixed Protocols.LysKOM.Session.Conference.aux_items
mixed Protocols.LysKOM.Session.Conference.name
mixed Protocols.LysKOM.Session.Conference.type
mixed Protocols.LysKOM.Session.Conference.creation_time
mixed Protocols.LysKOM.Session.Conference.last_written
mixed Protocols.LysKOM.Session.Conference.nice
mixed Protocols.LysKOM.Session.Conference.no_of_members
mixed Protocols.LysKOM.Session.Conference.first_local_no
mixed Protocols.LysKOM.Session.Conference.no_of_texts
mixed Protocols.LysKOM.Session.Conference.presentation
Undocumented
| Module Protocols.LysKOM.ProtocolTypes |
Data types as defined by the LysKOM protocol specification.
| Module Protocols.LysKOM.Request |
This module contains nice abstraction for calls into the server. They are named "call", "async_call" or "async_cb_call", depending on how you want the call to be done.
| CLASS Protocols.LysKOM.Request._Request |
This is the main request class. All lyskom request classes inherit this class.
void async(mixed ... args)
mixed sync(mixed ... args)
Initialise an asynchronous or a synchronous call, the latter is also evaluating the result. This calls indata() in itself, to get the correct arguments to the lyskom protocol call.
void _async(int call, mixed_data)
mixed _sync(int call, mixed_data)
Initialise an asynchronous or a synchronous call, the latter is also evaluating the result. These are called by async and sync respectively.
mixed _reply(object|array what)
mixed reply(object|array what)
_reply() is called as callback to evaluate the result, and calls reply() in itself to do the real work.
mixed `()()
Wait for the call to finish.
int(0..1) Protocols.LysKOM.Request._Request.ok
Tells if the call has executed ok
object Protocols.LysKOM.Request._Request.error
How the call failed.
The call has completed if (ok||error).
| Module Protocols.X |
| Module Protocols.X.Extensions |
| CLASS Protocols.X.Extensions.extension |
an abstract class used to provide features for implimenting X11 extensions. Provides no useful functionality on its own.
int init(object d)
initialize the extension.
An object of type Protocols.X.Xlib.Display
| CLASS Protocols.X.Extensions.XTEST |
Provides support for the X11 XTEST extension.
inherit extension : extension
void Protocols.X.Extensions.XTEST()
Create object.
int init(object display)
Initialize the XTEST extension. Returns 1 if successful.
Protocols.X.Display object
void XTestFakeInput(string event_type, int detail, int delay, object|void window, int|void xloc, int|void yloc)
Send a synthetic event to an X server.
Type of event to send. Possible values: KeyPress: 2, KeyRelease: 3, ButtonPress: 4, ButtonRelease: 5, MotionNotify: 6
Button (for Button events) or Keycode (for Key events) to send
Delay before the X server simulates event. 0 indicates zero delay.
Window object that a motion event occurrs in. If no window is provided, the root window will be used.
For motion events, this is the relative X distance or absolute X coordinates.
For motion events, this is the relative Y distance or absolute Y coordinates.
void XTestGrabControl(int impervious)
Cause the executing client to become impervious to server grabs. That is, it can continue to execute requests even if another client grabs the server.
A true (non zero) value causes the client to perform as described above. If false (zero), server returns to the normal state of being susceptible to server grabs.
| Module Protocols.HTTP |
.Query do_method(string method, string|Standards.URI url, void|mapping(string:int|string) query_variables, void|mapping(string:string|array(string)) request_headers, void|Protocols.HTTP.Query con, void|string data)
Low level HTTP call method.
The HTTP method to use, e.g. "GET".
The URL to perform method on. Should be a complete URL,
including protocol, e.g. "https://pike.ida.liu.se/".
Calls http_encode_query and appends the result to the URL.
The HTTP headers to be added to the request. By default the headers User-agent, Host and, if needed by the url, Authorization will be added, with generated contents. Providing these headers will override the default. Setting the value to 0 will remove that header from the request.
Old connection object.
Data payload to be transmitted in the request.
do_sync_method()
void do_async_method(string method, string|Standards.URI url, void|mapping(string:int|string) query_variables, void|mapping(string:string|array(string)) request_headers, Protocols.HTTP.Query con, void|string data)
Low level asynchronous HTTP call method.
The HTTP method to use, e.g. "GET".
The URL to perform method on. Should be a complete URL,
including protocol, e.g. "https://pike.ida.liu.se/".
Calls http_encode_query and appends the result to the URL.
The HTTP headers to be added to the request. By default the headers User-agent, Host and, if needed by the url, Authorization will be added, with generated contents. Providing these headers will override the default. Setting the value to 0 will remove that header from the request.
Previously initialized connection object. In particular the callbacks must have been set (Query.set_callbacks() ).
Data payload to be transmitted in the request.
do_method() , Query.set_callbacks()
.Query get_url(string|Standards.URI url, void|mapping(string:int|string) query_variables, void|mapping(string:string|array(string)) request_headers, void|Protocols.HTTP.Query con)
Sends a HTTP GET request to the server in the URL and returns the
created and initialized Query object. 0 is returned
upon failure. If a query object having
request_headers->Connection=="Keep-Alive" from a previous
request is provided and the already established server connection
can be used for the next request, you may gain some performance.
.Query put_url(string|Standards.URI url, void|string file, void|mapping(string:int|string) query_variables, void|mapping(string:string|array(string)) request_headers, void|Protocols.HTTP.Query con)
Sends a HTTP PUT request to the server in the URL and returns the
created and initialized Query object. 0 is returned upon
failure. If a query object having
request_headers->Connection=="Keep-Alive" from a previous
request is provided and the already established server connection
can be used for the next request, you may gain some performance.
.Query delete_url(string|Standards.URI url, void|mapping(string:int|string) query_variables, void|mapping(string:string|array(string)) request_headers, void|Protocols.HTTP.Query con)
Sends a HTTP DELETE request to the server in the URL and returns
the created and initialized Query object. 0 is returned
upon failure. If a query object having
request_headers->Connection=="Keep-Alive" from a previous
request is provided and the already established server connection
can be used for the next request, you may gain some performance.
array(string) get_url_nice(string|Standards.URI url, void|mapping(string:int|string) query_variables, void|mapping(string:string|array(string)) request_headers, void|Protocols.HTTP.Query con)
Returns an array of ({content_type, data}) after calling
the requested server for the information. 0 is returned
upon failure. Redirects (HTTP 302) are automatically followed.
string get_url_data(string|Standards.URI url, void|mapping(string:int|string) query_variables, void|mapping(string:string|array(string)) request_headers, void|Protocols.HTTP.Query con)
Returns the returned data after calling the requested server for
information through HTTP GET. 0 is returned upon failure.
Redirects (HTTP 302) are automatically followed.
.Query post_url(string|Standards.URI url, mapping(string:int|string) query_variables, void|mapping(string:string|array(string)) request_headers, void|Protocols.HTTP.Query con)
Similar to get_url , except that query variables is sent as a POST request instead of a GET request.
array(string) post_url_nice(string|Standards.URI url, mapping(string:int|string) query_variables, void|mapping(string:string|array(string)) request_headers, void|Protocols.HTTP.Query con)
Similar to get_url_nice , except that query variables is sent as a POST request instead of a GET request.
string post_url_data(string|Standards.URI url, mapping(string:int|string) query_variables, void|mapping(string:string|array(string)) request_headers, void|Protocols.HTTP.Query con)
Similar to get_url_data , except that query variables is sent as a POST request instead of a GET request.
string http_encode_query(mapping(string:int|string|array(string)) variables)
Encodes a query mapping to a string; this protects odd - in http perspective - characters like '&' and '#' and control characters, and packs the result together in a HTTP query string.
Example:
> Protocols.HTTP.http_encode_query( (["anna":"eva","lilith":"blue"]) );
Result: "lilith=blue&anna=eva"
> Protocols.HTTP.http_encode_query( (["&":"&","'=\"":"\0\0\0"]) );
Result: "%26amp%3b=%26&%27%3d%22=%00%00%00"
string percent_encode(string s)
Encodes the given string using %XX encoding, except that URI unreserved chars are not encoded. The unreserved chars are A-Z, a-z, 0-9, -, ., _, and ~ (see RFC 2396 section 2.3).
8-bit chars are encoded straight, and wider chars are not allowed. That means this encoding is applicable if s is a binary octet string. If it is a character string then uri_encode should be used instead.
It is also slightly faster than uri_encode if s is known to contain only US-ASCII.
string percent_decode(string s)
Decodes URI-style %XX encoded chars in the given string.
percent_encode , uri_decode
This function currently does not accept wide string input, which is necessary to work as the reverse of iri_encode .
string uri_encode(string s)
Encodes the given string using %XX encoding to be used as a component part in a URI. This means that all URI reserved and excluded characters are encoded, i.e. everything except A-Z, a-z, 0-9, -, ., _, and ~ (see RFC 2396 section 2.3).
8-bit chars and wider are encoded using UTF-8 followed by percent-encoding. This follows RFC 3986 section 2.5, the IRI-to-URI conversion method in the IRI standard (RFC 3987) and appendix B.2 in the HTML 4.01 standard. It should work regardless of the charset used in the XML document the URI might be inserted into.
uri_decode , uri_encode_invalids , iri_encode
string uri_encode_invalids(string s)
Encodes all "dangerous" chars in the given string using %XX encoding, so that it can be included as a URI in an HTTP message or header field. This includes control chars, space and various delimiter chars except those in the URI reserved set (RFC 2396 section 2.2).
Since this function doesn't touch the URI reserved chars nor the escape char %, it can be used on a complete formatted URI or IRI.
8-bit chars and wider are encoded using UTF-8 followed by percent-encoding. This follows RFC 3986 section 2.5, the IRI standard (RFC 3987) and appendix B.2 in the HTML 4.01 standard.
The characters in the URI reserved set are: :, /, ?, #, [, ], @, !, $, &, ', (, ), *, +, ,, ;, =. In addition, this function doesn't touch the escape char %.
uri_decode , uri_encode
string uri_decode(string s)
Decodes URI-style %XX encoded chars in the given string, and then UTF-8 decodes the result. This is the reverse of uri_encode and uri_encode_invalids .
uri_encode , uri_encode_invalids
string iri_encode(string s)
Encodes the given string using %XX encoding to be used as a component part in an IRI (Internationalized Resource Identifier, see RFC 3987). This means that all chars outside the IRI iunreserved set are encoded, i.e. this function encodes equivalently to uri_encode except that all 8-bit and wider characters are left as-is.
This function currently does not encode chars in the Unicode private ranges, although that is strictly speaking required in some but not all IRI components. That could change if it turns out to be a problem.
percent_decode , uri_encode
string uri_normalize(string s)
Normalizes the URI-style %XX encoded string s by decoding all URI unreserved chars, i.e. US-ASCII digits, letters, -, ., _, and ~.
Since only unreserved chars are decoded, the result is always semantically equivalent to the input. It's therefore safe to use this on a complete formatted URI.
uri_decode , uri_encode , iri_normalize
string iri_normalize(string s)
Normalizes the IRI-style UTF-8 and %XX encoded string s by decoding all IRI unreserved chars, i.e. everything except the URI reserved chars and control chars.
Since only unreserved chars are decoded, the result is always semantically equivalent to the input. It's therefore safe to use this on a complete formatted IRI.
iri_decode , uri_normalize
string quoted_string_encode(string s)
Encodes the given string quoted to be used as content inside a quoted-string according to RFC 2616 section 2.2. The returned string does not include the surrounding " chars.
The quoted-string quoting rules in RFC 2616 have several problems:
Quoting is inconsistent since " is quoted as \", but \ does not need to be quoted. This is resolved in the HTTP bis update to mandate quoting of \ too, which this function performs.
Many characters are not quoted sufficiently to make the result safe to use in an HTTP header, so this quoting is not enough if s contains NUL, CR, LF, or any 8-bit or wider character.
quoted_string_decode
string quoted_string_decode(string s)
Decodes the given string which has been encoded as a quoted-string according to RFC 2616 section 2.2. s is assumed to not include the surrounding " chars.
quoted_string_encode
__deprecated__ string http_encode_string(string in)
This is a deprecated alias for uri_encode , for compatibility with Pike 7.6 and earlier.
In 7.6 this function didn't handle 8-bit and wider chars correctly. It encoded 8-bit chars directly to %XX escapes, and it used nonstandard %uXXXX escapes for 16-bit chars.
That is considered a bug, and hence the function is changed. If
you need the old buggy encoding then use the 7.6 compatibility
version (#pike 7.6).
__deprecated__ string http_encode_cookie(string f)
This function used to claim that it encodes the specified string
according to the HTTP cookie standard. If fact it does not - it
applies URI-style (i.e. %XX) encoding on some of the
characters that cannot occur literally in cookie values. There
exist some web servers (read Roxen and forks) that usually perform
a corresponding nonstandard decoding of %-style escapes in cookie
values in received requests.
This function is deprecated. The function quoted_string_encode performs encoding according to the standard, but it is not safe to use with arbitrary chars. Thus URI-style encoding using uri_encode or percent_encode is normally a good choice, if you can use uri_decode /percent_decode at the decoding end.
__deprecated__ string unentity(string s)
Helper function for replacing HTML entities with the corresponding unicode characters.
| CLASS Protocols.HTTP.Query |
Open and execute an HTTP query.
HTTP.Query o=HTTP.Query();
void ok() { write("ok...\n"); write("%O\n", o->headers); exit(0); }
void fail() { write("fail\n"); exit(0); }
int main() { o->set_callbacks(ok, fail); o->async_request("pike.ida.liu.se", 80, "HEAD / HTTP/1.0"); return -1; }
int Protocols.HTTP.Query.errno
Errno copied from the connection.
int Protocols.HTTP.Query.ok
Tells if the connection is successfull.
mapping Protocols.HTTP.Query.headers
Headers as a mapping. All header names are in lower case, for convinience.
string Protocols.HTTP.Query.protocol
Protocol string, ie "HTTP/1.0".
int Protocols.HTTP.Query.status
string Protocols.HTTP.Query.status_desc
Status number and description (eg 200 and "ok").
mapping Protocols.HTTP.Query.hostname_cache
Set this to a global mapping if you want to use a cache, prior of calling *request().
Protocols.HTTP.Query set_callbacks(function request_ok, function request_fail, mixed ... extra)
Protocols.HTTP.Query async_request(string server, int port, string query)
Protocols.HTTP.Query async_request(string server, int port, string query, mapping headers, string|void data)
Setup and run an asynchronous request, otherwise similar to thread_request() .
request_ok (Protocols.HTTP.Query httpquery,...extra args) will be called when connection is complete, and headers are parsed.
request_fail (Protocols.HTTP.Query httpquery,...extra args) is called if the connection fails.
Returns the called object
Protocols.HTTP.Query thread_request(string server, int port, string query)
Protocols.HTTP.Query thread_request(string server, int port, string query, mapping headers, void|string data)
Create a new query object and begin the query.
The query is executed in a background thread; call `() in the object to wait for the request to complete.
query is the first line sent to the HTTP server;
for instance "GET /index.html HTTP/1.1".
headers will be encoded and sent after the first line, and data will be sent after the headers.
Returns the called object.
int `()()
Wait for connection to complete.
Returns 1 on successfull connection, 0 on failure.
string data(int|void max_length)
Gives back the data as a string.
string unicode_data()
Gives back data, but decoded according to the content-type character set.
data
int downloaded_bytes()
Gives back the number of downloaded bytes.
int total_bytes()
Gives back the size of a file if a content-length header is present and parsed at the time of evaluation. Otherwise returns -1.
array cast("array")
| ||||||||||||
mapping cast("mapping")
The header mapping ORed with the following mapping.
|
string cast("string")
Gives back the answer as a string.
Protocols.HTTP.Query.PseudoFile file()
Protocols.HTTP.Query.PseudoFile file(mapping newheaders, void|mapping removeheaders)
Gives back a pseudo-file object,
with the methods read() and close().
This could be used to copy the file to disc at
a proper tempo.
newheaders , removeheaders is applied as:
(oldheaders|newheaders))-removeheaders
Make sure all new and remove-header indices are lower case.
datafile()
Protocols.HTTP.Query.PseudoFile datafile()
Gives back a pseudo-file object,
with the methods read() and close().
This could be used to copy the file to disc at
a proper tempo.
datafile() doesn't give the complete request, just the data.
file()
void async_fetch(function callback, mixed ... extra)
Fetch all data in background.
timed_async_fetch() , async_request() , set_callbacks()
void timed_async_fetch(function(object:void) ok_callback, function(object:void) fail_callback, mixed ... extra)
Like async_fetch() , except with a timeout and a corresponding fail callback function.
async_fetch() , async_request() , set_callbacks()
| CLASS Protocols.HTTP.Session |
int Protocols.HTTP.Session.follow_redirects
The number of redirects to follow, if any. This is the default to the created Request objects.
A redirect automatically turns into a GET request, and all header, query, post or put information is dropped.
Default is 20 redirects. A negative number will mean infinity.
Loops will currently not be detected, only the limit works to stop loops.
Request.follow_redirects
mapping Protocols.HTTP.Session.default_headers
Default HTTP headers.
void set_http_cookie(string cookie, Standards.URI at)
Parse and set a cookie received in the HTTP protocol. The cookie will be checked against current security levels et al.
void set_cookie(Cookie cookie, Standards.URI who)
Set a cookie. The cookie will be checked against current security levels et al, using the parameter who . If who is zero, no security checks will be performed.
string encode_cookies()
void decode_cookies(string data, void no_clear)
Dump all cookies to a string and read them back. This is useful to store cookies in between sessions (on disk, for instance). decode_cookies will throw an error upon parse failures. Also note, decode_cookies will clear out any previously learned cookies from the Session object, unless no_clear is given and true.
array(string) get_cookies(Standards.URI|SessionURL for_url, void|int(0..1) no_delete)
Get the cookies that we should send to this server, for this url. They are presented in the form suitable for HTTP headers (as an array). This will also take in count expiration of cookies, and delete expired cookies from the Session unless no_delete is true.
mapping Protocols.HTTP.Session.hostname_cache
Cache of hostname to IP lookups. Given to and used by the Query objects.
int|float Protocols.HTTP.Session.time_to_keep_unused_connections
The time to keep unused connections in seconds. Set to zero to never save any kept-alive connections. (Might be good in a for instance totaly synchroneous script that keeps the backend thread busy and never will get call_outs.) Defaults to 10 seconds.
int Protocols.HTTP.Session.maximum_connections_per_server
Maximum number of connections to the same server. Used only by async requests. Defaults to 10 connections.
int Protocols.HTTP.Session.maximum_total_connections
Maximum total number of connections. Limits only async requests, and the number of kept-alive connections (live connections + kept-alive connections <= this number) Defaults to 50 connections.
int Protocols.HTTP.Session.maximum_connection_reuse
Maximum times a connection is reused. Defaults to 1000000. <2 means no reuse at all.
Query give_me_connection(Standards.URI url)
Request a Query object suitable to use for the given URL. This may be a reused object from a keep-alive connection.
void return_connection(Standards.URI url, Query query)
Return a previously used Query object to the keep-alive storage. This function will determine if the given object is suitable to keep or not by checking status and headers.
Request get_url(URL url, void|mapping query_variables)
Request post_url(URL url, mapping query_variables)
Request put_url(URL url, string file, void|mapping query_variables)
Request delete_url(URL url, void|mapping query_variables)
Sends a HTTP GET, POST, PUT or DELETE request to the server in the URL and returns the created and initialized Request object. 0 is returned upon failure.
array(string) get_url_nice(URL url, mapping query_variables)
string get_url_data(URL url, mapping query_variables)
array(string) post_url_nice(URL url, mapping query_variables)
string post_url_data(URL url, mapping query_variables)
Returns an array of ({content_type,data}) and
just the data string respective,
after calling the requested server for the information.
0 is returned upon failure.
post* is similar to the get_url() class of functions, except that the query variables is sent as a POST request instead of as a GET.
Request async_get_url(URL url, void|mapping query_variables, function callback_headers_ok, function callback_data_ok, function callback_fail, mixed ... callback_arguments)
Request async_put_url(URL url, void|string file, void|mapping query_variables, function callback_headers_ok, function callback_data_ok, function callback_fail, mixed ... callback_arguments)
Request async_delete_url(URL url, void|mapping query_variables, function callback_headers_ok, function callback_data_ok, function callback_fail, mixed ... callback_arguments)
Request async_post_url(URL url, mapping query_variables, function callback_headers_ok, function callback_data_ok, function callback_fail, mixed ... callback_arguments)
Sends a HTTP GET, POST, PUT or DELETE request to the server in the URL asynchroneously, and call the corresponding callbacks when result arrives (or not). The callbacks will receive the created Request object as first argument, then the given callback_arguments , if any.
callback_headers_ok is called when the HTTP request has received headers.
callback_data_ok is called when the HTTP request has been received completely, data and all.
callback_fail is called when the HTTP request has failed, on a TCP/IP or DNS level, or has received a forced timeout.
The created Request object is returned.
| CLASS Protocols.HTTP.Session.Request |
Request
Query Protocols.HTTP.Session.Request.con
Raw connection object
Standards.URI Protocols.HTTP.Session.Request.url_requested
URL requested (set by prepare_method). This will update according to followed redirects.
int Protocols.HTTP.Session.Request.follow_redirects
Number of redirects to follow; the request will perform another request if the HTTP answer is a 3xx redirect. Default from the parent Session.follow_redirects .
A redirect automatically turns into a GET request, and all header, query, post or put information is dropped.
Loops will currently not be detected, only the limit works to stop loops.
function(string:mixed) Protocols.HTTP.Session.Request.cookie_encountered
Cookie callback. When a request is performed, the result is checked for cookie changes and additions. If a cookie is encountered, this function is called. Default is to call set_http_cookie in the Session object.
array(string|int|mapping) prepare_method(string method, URL url, void|mapping query_variables, void|mapping extra_headers, void|string data)
Prepares the HTTP Query object for the connection, and returns the parameters to use with do_sync , do_async or do_thread .
This method will also use cookie information from the parent Session , and may reuse connections (keep-alive).
Request do_sync(array(string|int|mapping) args)
Perform a request synchronously. Get arguments from prepare_method .
0 upon failure, this object upon success
prepare_method , do_async , do_thread
Request do_thread(array(string|int|mapping) args)
Start a request in the background, using a thread. Call wait to wait for the thread to finish. Get arguments from prepare_method .
The called object.
prepare_method , do_sync , do_async , wait
do_thread does not rerun redirections automatically
Request wait()
Wait for the request thread to finish.
0 upon failure, or the called object upon success.
do_thread
void set_callbacks(function(mixed ... :mixed) headers, function(mixed ... :mixed) data, function(mixed ... :mixed) fail, mixed ... callback_arguments)
Setup callbacks for async mode, headers will be called when the request got connected, and got data headers; data will be called when the request got the amount of data it's supposed to get and fail is called whenever the request failed.
Note here that an error message from the server isn't considered a failure, only a failed TCP connection.
Request do_async(array(string|int|mapping) args)
Start a request asyncroneously. It will perform in the background using callbacks (make sure the backend thread is free). Call set_callbacks to setup the callbacks. Get arguments from prepare_method .
The called object.
set_callbacks , prepare_method , do_sync , do_thread
void destroy()
destroy is called when an object is destructed. But since this clears the HTTP connection from the Request object, it can also be used to reuse a Request object.
| CLASS Protocols.HTTP.Session.SessionURL |
Class to store URL+referer
inherit Standards.URI : URI
URL Protocols.HTTP.Session.SessionURL.referer
the referer to this URL
void Protocols.HTTP.Session.SessionURL(URL uri, URL base_uri, URL _referer)
instantiate a SessionURL object; when fed to Protocols.HTTP.Session calls, will add referer to the HTTP handshaking variables
| Module Protocols.HTTP.Server |
constant Protocols.HTTP.Server.HeaderParser
Fast HTTP header parser.
constant Protocols.HTTP.Server.http_decode_string
mapping(string:string|array(string)) http_decode_urlencoded_query(string query, void|mapping dest)
Decodes an URL-encoded query into a mapping.
string extension_to_type(string extension)
Looks up the file extension in a table to return a suitable MIME type.
string filename_to_type(string filename)
Looks up the file extension in a table to return a suitable MIME type.
string http_date(int time)
Makes a time notification suitable for the HTTP protocol.
The time in seconds since the 00:00:00 UTC, January 1, 1970
The date in the HTTP standard date format. Example : Thu, 03 Aug 2000 05:40:39 GMT
int http_decode_date(string data)
Decode a HTTP date to seconds since 1970 (UTC)
zero (UNDEFINED) if the given string isn't a HTTP date
| CLASS Protocols.HTTP.Server.Request |
string Protocols.HTTP.Server.Request.raw
raw unparsed full request (headers and body)
string Protocols.HTTP.Server.Request.body_raw
raw unparsed body of the request (raw minus request line and headers)
string Protocols.HTTP.Server.Request.request_raw
full request line (request_type + full_query + protocol )
string Protocols.HTTP.Server.Request.request_type
HTTP request method, eg. POST, GET, etc.
string Protocols.HTTP.Server.Request.full_query
full resource requested, including attached GET query
string Protocols.HTTP.Server.Request.not_query
resource requested minus any attached query
string Protocols.HTTP.Server.Request.query
query portion of requested resource, starting after the first "?"
string Protocols.HTTP.Server.Request.protocol
request protocol and version, eg. HTTP/1.0
mapping(string:string|array(string)) Protocols.HTTP.Server.Request.request_headers
all headers included as part of the HTTP request, ie content-type.
mapping(string:string|array(string)) Protocols.HTTP.Server.Request.variables
all variables included as part of a GET or POST request.
mapping(string:string) Protocols.HTTP.Server.Request.cookies
cookies set by client
mapping Protocols.HTTP.Server.Request.misc
external use only
int Protocols.HTTP.Server.Request.send_timeout_delay
send timeout (no activity for this period with data in send buffer) in seconds, default is 180
int Protocols.HTTP.Server.Request.connection_timeout_delay
connection timeout, delay until connection is closed while waiting for the correct headers:
void response_and_finish(mapping m, function|void _log_cb)
return a properly formatted response to the HTTP client
Contains elements for generating a response to the client.
|
int sent_data()
Returns the amount of data sent.
| CLASS Protocols.HTTP.Server.Port |
The simplest server possible. Binds a port and calls a callback with Server.Request objects.
void Protocols.HTTP.Server.Port(function(.Request:void) callback)
void Protocols.HTTP.Server.Port(function(.Request:void) callback, int portno, void|string interface)
void close()
Closes the HTTP port.
| CLASS Protocols.HTTP.Server.SSLPort |
The simplest SSL server possible. Binds a port and calls a callback with Request objects.
void Protocols.HTTP.Server.SSLPort(function(Request:void) _callback, void|int _portno, void|string _interface, void|string key, void|string|array certificate)
Create a HTTPS (HTTP over SSL) server.
The function run when a request is received. takes one argument of type Request .
The port number to bind to, defaults to 443.
The interface address to bind to.
An optional SSL secret key, provided in binary format, such as that created by Standards.PKCS.RSA.private_key() .
An optional SSL certificate or chain of certificates with the host certificate first, provided in binary format.
void close()
Closes the HTTP port.
void new_connection()
The port accept callback
| CLASS Protocols.HTTP.Server.SSLPort.MySSLPort |
inherit SSL.sslport : sslport
void set_default_keycert()
void set_key(string skey)
void set_certificate(string|array(string) certificate)
| Module Protocols.XMLRPC |
This module implements most features of the XML-RPC standard (see http://xml-rpc.org/).
Translation rules for conversions from Pike datatypes to XML-RPC datatypes:
Pike int is translated to XML-RPC <int>.
Pike string is translated to XML-RPC <string>.
Pike float is translated to XML-RPC <double>.
Pike mapping is translated to XML-RPC <struct>.
Pike array is translated to XML-RPC <array>.
Pike Calendar object is translated to XML-RPC <dateTime.iso8601.
Translation rules for conversions from XML-RPC datatypes to Pike datatypes:
XML-RPC <i4>, <int> and <boolean> are
translated to Pike int.
XML-RPC <string> and <base64> are translated to
Pike string.
XML_RPC <double> is translated to Pike float.
XML-RPC <struct> is translated to Pike mapping.
XML-RPC <array> is translated to Pike array.
XML-RPC <dateTime.iso8601> is translated to Pike Calendar object.
The XML-RPC <dateTime.iso8601> datatype does not assume any time zone, but local time is always used in the conversion to Calendar objects.
Call decode_call(string xml_input)
Decodes a XML-RPC representation of a function call and returns a Call object.
Call
array|Fault decode_response(string xml_input)
Decodes a XML-RPC representation of a response and returns an array containing response values, or a Fault object.
Fault
string encode_call(string method_name, array params)
Encodes a function call with the name method_name and the arguments params and returns the XML-RPC string representation.
string encode_response(array params)
Encodes a response containing the multiple values in params and returns the XML-RPC string representation.
string encode_response_fault(int fault_code, string fault_string)
Encodes a response fault containing a fault_code and a fault_string and returns the XML-RPC string representation.
| CLASS Protocols.XMLRPC.Call |
Represents a function call made to a XML-RPC server.
decode_call()
string Protocols.XMLRPC.Call.method_name
array Protocols.XMLRPC.Call.paramsvoid Protocols.XMLRPC.Call(string method_name, array params)
int Protocols.XMLRPC.Call.method_name
Represents <methodName> in the XML-RPC standard.
array Protocols.XMLRPC.Call.params
Represents <params> in the XML-RPC standard where all datatypes have been converted to equivalent or similar datatypes in Pike.
| CLASS Protocols.XMLRPC.Fault |
Represents a fault response which can be one of the return values from a XML-RPC function call.
decode_response()
int Protocols.XMLRPC.Fault.fault_code
string Protocols.XMLRPC.Fault.fault_stringvoid Protocols.XMLRPC.Fault(int fault_code, string fault_string)
int Protocols.XMLRPC.Fault.fault_code
Represents faultCode in the XML-RPC standard.
int Protocols.XMLRPC.Fault.fault_string
Represents faultString in the XML-RPC standard.
| CLASS Protocols.XMLRPC.Client |
This class implements an XML-RPC client that uses HTTP transport.
> Protocols.XMLRPC.Client client = Protocols.XMLRPC.Client("http://www.oreillynet.com/meerkat/xml-rpc/server.php"); Result: Protocols.XMLRPC.Client("http://www.oreillynet.com/meerkat/xml-rpc/server.php"); > client["system.listMethods"](); Result: ({ /* 1 element */ ({ /* 9 elements */ "meerkat.getChannels", "meerkat.getCategories", "meerkat.getCategoriesBySubstring", "meerkat.getChannelsByCategory", "meerkat.getChannelsBySubstring", "meerkat.getItems", "system.listMethods", "system.methodHelp", "system.methodSignature" }) })
string|Standards.URI Protocols.XMLRPC.Client.urlvoid Protocols.XMLRPC.Client(string|Standards.URI url)
| CLASS Protocols.XMLRPC.AsyncClient |
This class implements an XML-RPC client that uses HTTP transport using non blocking sockets.
void data_ok(mixed result) { write("result=%O\n", result); } void fail() { write("fail\n"); } int main(int argc, array argv) { object async_client = Protocols.XMLRPC.AsyncClient("http://www.oreillynet.com/meerkat/xml-rpc/server.php"); async_client["system.listMethods"](data_ok, fail); return -1;
| Module Protocols.IRC |
| CLASS Protocols.IRC.Person |
Abstract class for a person.
string Protocols.IRC.Person.nick
User nickname, e.g. "Mirar".
string Protocols.IRC.Person.user
User name, e.g. "mirar".
string Protocols.IRC.Person.ip
User domain, e.g. "mistel.idonex.se".
int Protocols.IRC.Person.last_action
Time of last action, represented as posix time.
| CLASS Protocols.IRC.Channel |
Abstract class for a IRC channel.
string Protocols.IRC.Channel.name
The name of the channel.
| CLASS Protocols.IRC.Client |
void Protocols.IRC.Client(string server, void|mapping(string:mixed) options)
The IRC server to connect to.
An optional mapping with additional IRC client options.
|
void close()
Closes the connection to the server.
| Module Protocols.Bittorrent |
| CLASS Protocols.Bittorrent.Torrent |
Bittorrent peer - download and share. Read more about bittorrent at http://bitconjurer.org/BitTorrent/introduction.html
The smallest usable torrent downloader. As first argument, it expects a filename to a .torrent file.
int main(int ac,array am) { // initialize Torrent from file: Protocols.Bittorrent.Torrent t=Protocols.Bittorrent.Torrent(); t->load_metainfo(am[1]);
// Callback when download status changes: // t->downloads_update_status=...;
// Callback when pieces status change (when we get new stuff): // t->pieces_update_status=...;
// Callback when peer status changes (connect, disconnect, choked...): // t->peer_update_status=...;
// Callback when download is completed: t->download_completed_callback= lambda() { call_out(exit,3600,0); // share for an hour, then exit };
// Callback to print warnings (same args as sprintf): // t->warning=werror;
// type of progress function used below: void progress(int n,int of) { /* ... */ };
// Initiate targets from Torrent, // if target was created, no need to verify: if (t->fix_targets(1,0,progress)==1) t->verify_targets(progress);
// Open port to listen on, // we want to do this to be able to talk to firewalled peers: t->open_port(6881);
// Ok, start calling tracker to get peers, // and tell about us: t->start_update_tracker();
// Finally, start the download: t->start_download();
return -1; }
function(.Peer:int(0..1)) Protocols.Bittorrent.Torrent.do_we_strangle
Function to determine if we should strangle this peer. Default is to allow 100000 bytes of data over the ratio, which is 2:1 per default; upload twice as much as we get.
Arguments are the peer, bytes in (downloaded) and bytes out (uploaded). Return 1 to strangle and 0 to allow the peer to proceed downloading again.
function Protocols.Bittorrent.Torrent.pieces_update_status
If set, called when we got another piece downloaded (no args).
function Protocols.Bittorrent.Torrent.downloads_update_status
If set, called when we start to download another piece (no args).
function Protocols.Bittorrent.Torrent.peer_update_status
If set, called when peer status changes.
function Protocols.Bittorrent.Torrent.download_completed_callback
If set, called when download is completed.
function(string:void|mixed) Protocols.Bittorrent.Torrent.warning
Called if there is a protocol error.
void load_metainfo(string filename)
Loads the metainfo from a file.
int fix_targets(void|int(-1..2) allocate, void|string base_filename, void|function(int:void) progress_callback)
Opens target datafile(s).
If all files are created, the verify info will be filled as well, but if it isn't created, a call to verify_target() is necessary after this call.
Determines allocation procedure if the file doesn't exist:
|
A new base filename to substitute the metainfo base target filename with.
|
void verify_targets(void|function(int:void) progress_callback)
Verify the file and fill file_got (necessary after load_info, but needs open_file before this call). [ progress_callback(at chunk,total chunks) ]
void open_port(void|int port)
Open the port we're listening on.
int bytes_done()
Calculate the bytes successfully downloaded (full pieces).
int bytes_left()
Calculate the bytes left to download.
void update_tracker(void|string event, void|int contact)
Contact and update the tracker with current status will fill the peer list.
void start_update_tracker(void|int interval)
Starts to contact the tracker at regular intervals, giving it the status and recieving more peers to talk to. Will also contact these peers. The default interval is 5 minutes. If given an event, will update tracker with it.
void stop_update_tracker(void|string event)
Stops updating the tracker; will send the event as a last event, if set. It will not contact new peers.
void contact_peers(void|int n)
Contact all or n peers.
string file_got_bitfield()
Returns the file got field as a string bitfield (cached).
void start_download()
Initiate the downloading scheme.
| CLASS Protocols.Bittorrent.Torrent.Target |
Each bittorrent has one or more target files. This represents one of those.
string Protocols.Bittorrent.Torrent.Target.base
int Protocols.Bittorrent.Torrent.Target.length
int Protocols.Bittorrent.Torrent.Target.offset
void|array Protocols.Bittorrent.Torrent.Target.pathvoid Protocols.Bittorrent.Torrent.Target(string base, int length, int offset, void|array path)
| CLASS Protocols.Bittorrent.Tracker |
int(0..) Protocols.Bittorrent.Tracker.interval
The query interval reported back to clients. Defaults to
1800.
int(0..1) Protocols.Bittorrent.Tracker.dynamic_add_torrents
Allow clients to dynamically add torrents to the tracker.
void add_torrent(string id)
Add a torrent to the tracker.
The info hash of the torrent file.
string announce(mapping args, string ip)
Handles HTTP announce queries to the tracker.
string scrape(mapping args)
Returns the result of a scrape query.
| CLASS Protocols.Bittorrent.Peer |
int is_connectable()
Returns true if we can connect to this peer, when new or disconnected but not fatally.
int is_online()
Returns true if this peer is online and connected.
int is_completed()
Returns true if this peer is completed, as in has downloaded everything already - and we shouldn't need to upload to get stuff.
int is_available()
Returns true if this peer is available, as in we can use it to download stuff.
int is_activated()
Returns true if this peer is activated, as in we're downloading from it.
int is_strangled()
Returns true if this peer is strangled; as in we don't want to upload more, because we're not getting any back.
int is_choked()
Returns true if this peer is choking, as in doesn't send more data to us.
multiset(int) downloading_pieces()
Returns as multiset what this peer is downloading.
void connect()
Connect to the peer; this is done async.
status/mode will change from "connecting" to
"dead" or to "connected" depending on result.
Will throw error if already online.
Upon connect, protocol will be initiated in choked mode.
When the protocol is up, status will change to "online"
(or "failed" if the handshake failed).
void disconnect()
Disconnect a peer.
Does nothing if we aren't online.
status/mode will change to "disconnected",1 if we were online.
void send_have(int n)
Send a have message to tell I now have piece n. Ignored if not online.
void request(int piece, int offset, int bytes, function(int:void|mixed) callback)
Called to request a chunk from this peer.
void status(string type, void|int|string data)
Called whenever there is a status change for this peer.
Always called with "created" when the object is created.
Does not need to call inherited function.
| CLASS Protocols.Bittorrent.Generator |
Generate a .torrent binary string from files in the filesystem
// usage: thisprogram [<file/dir>] [<file/dir>...] <target .torrent> int main(int ac,array am) { Generator g=Generator(); foreach (am[1..<1];;string f) g->add(f);
string dest=am[-1]; if (-1==search(dest,"torrent")) dest+=".torrent";
Stdio.write_file(dest,g->digest()); return 0; }
inherit .Torrent : Torrent
void Protocols.Bittorrent.Generator(void|string base, void|int piece_size)
Create a generator.
The base filename/path in the torrent.
The size of the pieces that the SHA hashes are calculated on. Default 262144 and this value should probably be 2^n.
this_program add_announce(string|array(string) announce_url)
Add one or multiple announcers (trackers). This is needed to get a valid .torrent file. If this is called more then once, more announcers (trackers) will be added with lower priority.
this_program add_file(string path, void|string filename)
Add a file to the torrent. The second argument is what the file will be called in the torrent.
this_program add_directory_tree(string path, void|string dirbase)
Add a directory tree to the torrent. The second argument is what the directory will be called in the torrent. This will call add_file on all non-directories in the tree.
this_program add(string path, void|string base)
Add a file, or a directory tree to the torrent. This will call add_directory_tree or add_file.
void build_sha1s(void|function(int:void) progress_callback)
Build the SHA hashes from the files.
string digest(void|function(int:void) progress_callback)
Finally make a torrent string out of this information. Will call build_sha1's if the sha1's aren't generated already.
progress_callback is called with (pos,of) arguments, similar to Torrent.verify_targets .
| CLASS Protocols.Bittorrent.Port |
void Protocols.Bittorrent.Port(.Torrent _parent)
Bind a port for this Torrent.
| Module Protocols.Bittorrent.Bencoding |
array(string|int|array|mapping) _decode(string what)
Decodes a Bittorrent bencoded data chunk.
| ||||||
string|int|array|mapping decode(string what)
Decodes a Bittorrent bencoded data chunk and ignores the remaining string. Returns UNDEFINED if the data is incomplete.
string encode(string|int|array|mapping data)
Encodes a Bittorrent bencoded data chunk.
string bits2string(array(int(0..1)) v)
Convert an array of int(0..1) to a Bittorrent style
bitstring. Input will be padded to even bytes.
array(int(0..1)) string2bits(string s)
Convert a Bittorrent style bitstring to an array of
int(0..1).
array(int) string2arr(string s)
Convert a Bittorrent style bitstring to an array of indices.
| Module Protocols.Bittorrent.PeerID |
string identify_peer(string peerid)
Decodes the given peerid , returning an identification string for the client software. Assumes the peerid string is exactly 20 characters long.
| Module Protocols.LDAP |
constant Protocols.LDAP.LDAP_SUCCESS
constant Protocols.LDAP.LDAP_OPERATIONS_ERROR
constant Protocols.LDAP.LDAP_PROTOCOL_ERROR
constant Protocols.LDAP.LDAP_TIMELIMIT_EXCEEDED
constant Protocols.LDAP.LDAP_SIZELIMIT_EXCEEDED
constant Protocols.LDAP.LDAP_COMPARE_FALSE
constant Protocols.LDAP.LDAP_COMPARE_TRUE
constant Protocols.LDAP.LDAP_AUTH_METHOD_NOT_SUPPORTED
constant Protocols.LDAP.LDAP_STRONG_AUTH_NOT_SUPPORTED
constant Protocols.LDAP.LDAP_STRONG_AUTH_REQUIRED
constant Protocols.LDAP.LDAP_PARTIAL_RESULTS
constant Protocols.LDAP.LDAP_REFERRAL
constant Protocols.LDAP.LDAP_ADMINLIMIT_EXCEEDED
constant Protocols.LDAP.LDAP_UNAVAILABLE_CRITICAL_EXTENSION
constant Protocols.LDAP.LDAP_CONFIDENTIALITY_REQUIRED
constant Protocols.LDAP.LDAP_SASL_BIND_IN_PROGRESS
constant Protocols.LDAP.LDAP_NO_SUCH_ATTRIBUTE
constant Protocols.LDAP.LDAP_UNDEFINED_TYPE
constant Protocols.LDAP.LDAP_INAPPROPRIATE_MATCHING
constant Protocols.LDAP.LDAP_CONSTRAINT_VIOLATION
constant Protocols.LDAP.LDAP_TYPE_OR_VALUE_EXISTS
constant Protocols.LDAP.LDAP_INVALID_SYNTAX
constant Protocols.LDAP.LDAP_NO_SUCH_OBJECT
constant Protocols.LDAP.LDAP_ALIAS_PROBLEM
constant Protocols.LDAP.LDAP_INVALID_DN_SYNTAX
constant Protocols.LDAP.LDAP_IS_LEAF
constant Protocols.LDAP.LDAP_ALIAS_DEREF_PROBLEM
constant Protocols.LDAP.LDAP_INAPPROPRIATE_AUTH
constant Protocols.LDAP.LDAP_INVALID_CREDENTIALS
constant Protocols.LDAP.LDAP_INSUFFICIENT_ACCESS
constant Protocols.LDAP.LDAP_BUSY
constant Protocols.LDAP.LDAP_UNAVAILABLE
constant Protocols.LDAP.LDAP_UNWILLING_TO_PERFORM
constant Protocols.LDAP.LDAP_LOOP_DETECT
constant Protocols.LDAP.LDAP_SORT_CONTROL_MISSING
constant Protocols.LDAP.LDAP_NAMING_VIOLATION
constant Protocols.LDAP.LDAP_OBJECT_CLASS_VIOLATION
constant Protocols.LDAP.LDAP_NOT_ALLOWED_ON_NONLEAF
constant Protocols.LDAP.LDAP_NOT_ALLOWED_ON_RDN
constant Protocols.LDAP.LDAP_ALREADY_EXISTS
constant Protocols.LDAP.LDAP_NO_OBJECT_CLASS_MODS
constant Protocols.LDAP.LDAP_RESULTS_TOO_LARGE
constant Protocols.LDAP.LDAP_AFFECTS_MULTIPLE_DSAS
constant Protocols.LDAP.LDAP_OTHER
constant Protocols.LDAP.LDAP_SERVER_DOWN
constant Protocols.LDAP.LDAP_LOCAL_ERROR
constant Protocols.LDAP.LDAP_ENCODING_ERROR
constant Protocols.LDAP.LDAP_DECODING_ERROR
constant Protocols.LDAP.LDAP_TIMEOUT
constant Protocols.LDAP.LDAP_AUTH_UNKNOWN
constant Protocols.LDAP.LDAP_FILTER_ERROR
constant Protocols.LDAP.LDAP_USER_CANCELLED
constant Protocols.LDAP.LDAP_PARAM_ERROR
constant Protocols.LDAP.LDAP_NO_MEMORY
constant Protocols.LDAP.LDAP_CONNECT_ERROR
constant Protocols.LDAP.LDAP_NOT_SUPPORTED
constant Protocols.LDAP.LDAP_CONTROL_NOT_FOUND
constant Protocols.LDAP.LDAP_NO_RESULTS_RETURNED
constant Protocols.LDAP.LDAP_MORE_RESULTS_TO_RETURN
constant Protocols.LDAP.LDAP_CLIENT_LOOP
constant Protocols.LDAP.LDAP_REFERRAL_LIMIT_EXCEEDED
LDAP result codes.
Protocols.LDAP.client.error_number , Protocols.LDAP.client.result.error_number
constant Protocols.LDAP.ldap_error_strings
Mapping from LDAP_* result codes to descriptive strings.
constant Protocols.LDAP.SEARCH_LOWER_ATTRS
constant Protocols.LDAP.SEARCH_MULTIVAL_ARRAYS_ONLY
constant Protocols.LDAP.SEARCH_RETURN_DECODE_ERRORS
Bitfield flags given to Protocols.LDAP.client.search :
Lowercase all attribute values. This makes it easier to match specific attributes in the mappings returned by Protocols.LDAP.client.result.fetch since LDAP attribute names are case insensitive.
Only use arrays for attribute values where the attribute syntax specify multiple values. I.e. the values for single valued attributes are returned as strings instead of arrays containing one string element.
If no value is returned for a single valued attribute, e.g. when
attrsonly is set in the search call, then a zero will be
used as value.
The special "dn" value is also returned as a string when
this flag is set.
Note that it's the attribute type descriptions that are used to decide this, not the number of values a particular attribute happens to have in the search result.
Don't throw attribute value decode errors, instead return them in the result from Protocols.LDAP.client.result.fetch in place of the value. I.e. anywhere an attribute value string occurs, you might instead have a Locale.Charset.DecodeError object.
constant Protocols.LDAP.SCOPE_BASE
constant Protocols.LDAP.SCOPE_ONE
constant Protocols.LDAP.SCOPE_SUB
Constants for the search scope used with e.g. Protocols.LDAP.client.set_scope .
Return the object specified by the DN.
Return the immediate subobjects of the object specified by the DN.
Return the object specified by the DN and all objects below it (on any level).
constant Protocols.LDAP.MODIFY_ADD
constant Protocols.LDAP.MODIFY_DELETE
constant Protocols.LDAP.MODIFY_REPLACE
Constants used in the attropval argument to
Protocols.LDAP.client.modify .
string ldap_encode_string(string str)
Quote characters in the given string as necessary for use as a string literal in filters and various composite LDAP attributes.
The quoting is compliant with RFCs 2252 (section 4.3) and 2254
(section 4). All characters that can be special in those RFCs are
quoted using the \xx syntax, but the set might be
extended.
ldap_decode_string , Protocols.LDAP.client.search
string ldap_decode_string(string str)
Decodes all \xx escapes in str .
ldap_encode_string
string encode_dn_value(string str)
Encode the given string for use as an attribute value in a distinguished name (on string form).
The encoding is according to RFC 2253 section 2.4 with the
exception that characters above 0x7F aren't UTF-8 encoded.
UTF-8 encoding can always be done afterwards on the complete DN,
which also is done internally by the Protocols.LDAP functions
when LDAPv3 is used.
string canonicalize_dn(string dn, void|int strict)
Returns the given distinguished name on a canonical form, so it reliably can be used in comparisons for equality. This means removing surplus whitespace, lowercasing attributes, normalizing quoting in string attribute values, lowercasing the hex digits in binary attribute values, and sorting the RDN parts separated by "+".
The returned string follows RFC 2253. The input string may use legacy LDAPv2 syntax and is treated according to section 4 in RFC 2253.
If strict is set then errors will be thrown if the given DN is syntactically invalid. Otherwise the invalid parts remain untouched in the result.
The result is not entirely canonical since no conversion is done from or to hexadecimal BER encodings of the attribute values. It's assumed that the input already has the suitable value encoding depending on the attribute type.
No UTF-8 encoding or decoding is done. The function can be used on both encoded and decoded input strings, and the result will be likewise encoded or decoded.
constant Protocols.LDAP.LDAP_CONTROL_MANAGE_DSA_IT
LDAP control: Manage DSA IT LDAPv3 control (RFC 3296): Control to indicate that the operation is intended to manage objects within the DSA (server) Information Tree.
constant Protocols.LDAP.LDAP_CONTROL_VLVREQUEST
LDAP control: LDAP Extensions for Scrolling View Browsing of Search Results (internet draft): Control used to request virtual list view support from the server.
constant Protocols.LDAP.LDAP_CONTROL_VLVRESPONSE
LDAP control: LDAP Extensions for Scrolling View Browsing of Search Results (internet draft): Control used to pass virtual list view (VLV) data from the server to the client.
constant Protocols.LDAP.LDAP_PAGED_RESULT_OID_STRING
LDAP control: Microsoft AD: Control to instruct the server to return the results of a search request in smaller, more manageable packets rather than in one large block.
constant Protocols.LDAP.LDAP_SERVER_ASQ_OID
LDAP control: Microsoft AD: Control to force the query to be based on a specific DN-valued attribute.
constant Protocols.LDAP.LDAP_SERVER_CROSSDOM_MOVE_TARGET_OID
LDAP control: Microsoft AD: Control used with an extended LDAP rename function to move an LDAP object from one domain to another.
constant Protocols.LDAP.LDAP_SERVER_DIRSYNC_OID
LDAP control: Microsoft AD: Control that enables an application to search the directory for objects changed from a previous state.
constant Protocols.LDAP.LDAP_SERVER_DOMAIN_SCOPE_OID
LDAP control: Microsoft AD: Control used to instruct the LDAP server not to generate any referrals when completing a request.
constant Protocols.LDAP.LDAP_SERVER_EXTENDED_DN_OID
LDAP control: Microsoft AD: Control to request an extended form of an Active Directory object distinguished name.
constant Protocols.LDAP.LDAP_SERVER_LAZY_COMMIT_OID
LDAP control: Microsoft AD: Control used to instruct the server to return the results of a DS modification command, such as add, delete, or replace, after it has been completed in memory, but before it has been committed to disk.
constant Protocols.LDAP.LDAP_SERVER_NOTIFICATION_OID
LDAP control: Microsoft AD: Control used with an extended LDAP asynchronous search function to register the client to be notified when changes are made to an object in Active Directory.
constant Protocols.LDAP.LDAP_SERVER_PERMISSIVE_MODIFY_OID
LDAP control: Microsoft AD: An LDAP modify request will normally fail if it attempts to add an attribute that already exists, or if it attempts to delete an attribute that does not exist. With this control, as long as the attribute to be added has the same value as the existing attribute, then the modify will succeed. With this control, deletion of an attribute that does not exist will also succeed.
constant Protocols.LDAP.LDAP_SERVER_QUOTA_CONTROL_OID
LDAP control: Microsoft AD: Control used to pass the SID of a security principal, whose quota is being queried, to the server in a LDAP search operation.
constant Protocols.LDAP.LDAP_SERVER_RESP_SORT_OID
LDAP control: Microsoft AD: Control used by the server to indicate the results of a search function initiated using the LDAP_SERVER_SORT_OID control.
constant Protocols.LDAP.LDAP_SERVER_SD_FLAGS_OID
LDAP control: Microsoft AD: Control used to pass flags to the server to control various security descriptor results.
constant Protocols.LDAP.LDAP_SERVER_SEARCH_OPTIONS_OID
LDAP control: Microsoft AD: Control used to pass flags to the server to control various search behaviors.
constant Protocols.LDAP.LDAP_SERVER_SHOW_DELETED_OID
LDAP control: Microsoft AD: Control used to specify that the search results include any deleted objects that match the search filter.
constant Protocols.LDAP.LDAP_SERVER_SORT_OID
LDAP control: Microsoft AD: Control used to instruct the server to sort the search results before returning them to the client application.
constant Protocols.LDAP.LDAP_SERVER_TREE_DELETE_OID
LDAP control: Microsoft AD: Control used to delete an entire subtree in the directory.
constant Protocols.LDAP.LDAP_SERVER_VERIFY_NAME_OID
LDAP control: Microsoft AD: Control used to instruct the DC accepting the update which DC it should verify with, the existence of any DN attribute values.
constant Protocols.LDAP.SYNTAX_ATTR_TYPE_DESCR
constant Protocols.LDAP.SYNTAX_BINARY
constant Protocols.LDAP.SYNTAX_BIT_STRING
constant Protocols.LDAP.SYNTAX_BOOLEAN
constant Protocols.LDAP.SYNTAX_CERT
constant Protocols.LDAP.SYNTAX_CERT_LIST
constant Protocols.LDAP.SYNTAX_CERT_PAIR
constant Protocols.LDAP.SYNTAX_COUNTRY_STR
constant Protocols.LDAP.SYNTAX_DN
constant Protocols.LDAP.SYNTAX_DIRECTORY_STR
constant Protocols.LDAP.SYNTAX_DIT_CONTENT_RULE_DESCR
constant Protocols.LDAP.SYNTAX_FACSIMILE_PHONE_NUM
constant Protocols.LDAP.SYNTAX_FAX
constant Protocols.LDAP.SYNTAX_GENERALIZED_TIME
constant Protocols.LDAP.SYNTAX_IA5_STR
constant Protocols.LDAP.SYNTAX_INT
constant Protocols.LDAP.SYNTAX_JPEG
constant Protocols.LDAP.SYNTAX_MATCHING_RULE_DESCR
constant Protocols.LDAP.SYNTAX_MATCHING_RULE_USE_DESCR
constant Protocols.LDAP.SYNTAX_MHS_OR_ADDR
constant Protocols.LDAP.SYNTAX_NAME_AND_OPTIONAL_UID
constant Protocols.LDAP.SYNTAX_NAME_FORM_DESCR
constant Protocols.LDAP.SYNTAX_NUMERIC_STRING
constant Protocols.LDAP.SYNTAX_OBJECT_CLASS_DESCR
constant Protocols.LDAP.SYNTAX_OID
constant Protocols.LDAP.SYNTAX_OTHER_MAILBOX
constant Protocols.LDAP.SYNTAX_POSTAL_ADDR
constant Protocols.LDAP.SYNTAX_PRESENTATION_ADDR
constant Protocols.LDAP.SYNTAX_PRINTABLE_STR
constant Protocols.LDAP.SYNTAX_PHONE_NUM
constant Protocols.LDAP.SYNTAX_UTC_TIME
constant Protocols.LDAP.SYNTAX_LDAP_SYNTAX_DESCR
constant Protocols.LDAP.SYNTAX_DIT_STRUCTURE_RULE_DESCR
LDAP syntax: Standard syntaxes from RFC 2252.
constant Protocols.LDAP.SYNTAX_CASE_EXACT_STR
"caseExactString" is an alias used in e.g. RFC 2079.
constant Protocols.LDAP.SYNTAX_DELIVERY_METHOD
constant Protocols.LDAP.SYNTAX_ENHANCED_GUIDE
constant Protocols.LDAP.SYNTAX_GUIDE
constant Protocols.LDAP.SYNTAX_OCTET_STR
constant Protocols.LDAP.SYNTAX_TELETEX_TERMINAL_ID
constant Protocols.LDAP.SYNTAX_TELETEX_NUM
constant Protocols.LDAP.SYNTAX_SUPPORTED_ALGORITHM
LDAP syntax: Standard syntaxes from RFC 2256.
constant Protocols.LDAP.SYNTAX_AD_CASE_IGNORE_STR
constant Protocols.LDAP.SYNTAX_AD_LARGE_INT
constant Protocols.LDAP.SYNTAX_AD_OBJECT_SECURITY_DESCRIPTOR
LDAP syntax: Microsoft AD: Additional syntaxes used in AD. C.f. <http://community.roxen.com/(all)/developers/idocs/drafts/ draft-armijo-ldap-syntax-00.html>.
constant Protocols.LDAP.mapping
Mapping containing functions to decode charsets in syntaxes where that's necessary. If the syntax is complex in a way that makes the result ambiguous if decoded with a single charset transformation then it should typically not be decoded here.
These decoders are used on all attribute values returned by Protocols.LDAP.client.result functions.
constant Protocols.LDAP.mapping
Mapping containing the reverse functions from syntax_decode_fns .
constant Protocols.LDAP.GUID_USERS_CONTAINER
constant Protocols.LDAP.GUID_COMPUTERS_CONTAINER
constant Protocols.LDAP.GUID_SYSTEMS_CONTAINER
constant Protocols.LDAP.GUID_DOMAIN_CONTROLLERS_CONTAINER
constant Protocols.LDAP.GUID_INFRASTRUCTURE_CONTAINER
constant Protocols.LDAP.GUID_DELETED_OBJECTS_CONTAINER
constant Protocols.LDAP.GUID_LOSTANDFOUND_CONTAINER
constant Protocols.LDAP.GUID_FOREIGNSECURITYPRINCIPALS_CONTAINER
constant Protocols.LDAP.GUID_PROGRAM_DATA_CONTAINER
constant Protocols.LDAP.GUID_MICROSOFT_PROGRAM_DATA_CONTAINER
constant Protocols.LDAP.GUID_NTDS_QUOTAS_CONTAINER
Constants for Microsoft AD Well-Known Object GUIDs. These are e.g. used in LDAP URLs:
"ldap://server/<WKGUID=" + Protocols.LDAP.GUID_USERS_CONTAINER +
",dc=my,dc=domain,dc=com>"
string get_constant_name(mixed val)
If val matches any non-integer constant in this module, its name is returned.
mapping(string:mixed) parse_ldap_url(string ldap_url)
Parses an LDAP URL and returns its fields in a mapping.
The returned mapping contains these fields:
|
get_parsed_url
object make_filter(string filter, void|int ldap_version)
Parses an LDAP filter string into an ASN1 object tree that can be given to Protocols.LDAP.search .
Using this function instead of giving the filter string directly to the search function has two advantages: This function provides better error reports for syntax errors, and the same object tree can be used repeatedly to avoid reparsing the filter string.
The filter to parse, according to the syntax specified in RFC 2254. The syntax is extended a bit to allow and ignore whitespace everywhere except inside and next to the filter values.
LDAP protocol version to make the filter for. This controls what
syntaxes are allowed depending on the protocol version. Also, if
the protocol is 3 or later then full Unicode string
literals are supported. The default is the latest supported
version.
An ASN1 object tree representing the filter.
FilterError is thrown if there's a syntax error in the filter.
object get_cached_filter(string filter, void|int ldap_version)
Like make_filter but saves the generated objects for reuse. Useful for filters that reasonably will occur often. The cache is never garbage collected, however.
If there's a parse error in the filter then a FilterError is thrown as from make_filter .
object get_connection(string ldap_url, void|string binddn, void|string password, void|int version)
Returns a client connection to the specified LDAP URL. If a bind
DN is specified (either through a "bindname" extension in
ldap_url or, if there isn't one, through binddn ) then the
connection will be bound using that DN and the optional password.
If no bind DN is given then any connection is returned, regardless
of the bind DN it is using.
version may be used to specify the required protocol version in
the bind operation. If zero or left out, a bind attempt with the
default version (currently 3) is done with a fallback to
2 if that fails. Also, a cached connection for any version
might be returned if version isn't specified.
As opposed to creating an Protocols.LDAP.client instance directly, this function can return an already established connection for the same URL, provided connections are given back using return_connection when they aren't used anymore.
A client object with an error condition is returned if there's a bind error, e.g. invalid password.
void return_connection(object conn)
Use this to return a connection to the connection pool after you've finished using it. The connection is assumed to be working.
Ensure that persistent connection settings such as the scope and the base DN are restored to the defaults
int num_connections(string ldap_url)
Returns the number of currently stored connections for the given LDAP URL.
| CLASS Protocols.LDAP.client |
Contains the client implementation of the LDAP protocol. All of the version 2 protocol features are implemented but only the base parts of the version 3.
inherit .protocol : protocol
mapping Protocols.LDAP.client.info
Several information about code itself and about active connection too
void Protocols.LDAP.client()
void Protocols.LDAP.client(string url)
void Protocols.LDAP.client(string url, object context)
Create object. The first optional argument can be used later for subsequence operations. The second one can specify TLS context of connection. The default context only allows 128-bit encryption methods, so you may need to provide your own context if your LDAP server supports only export encryption.
LDAP server URL on the form
"ldap://hostname/basedn?attrlist?scope?ext". See RFC
2255. It can also be a mapping as returned by
Protocol.LDAP.parse_ldap_url .
TLS context of connection
LDAP.client.bind , LDAP.client.search
void reset_options()
Resets all connection options, such as the scope and the base DN, to the defaults determined from the LDAP URL when the connection was created.
int start_tls(void|SSL.context context)
Requests that a SSL/TLS session be negotiated on the connection. If the connection is already secure, this call will fail.
an optional SSL.context object to provide to the SSL/TLS connection client.
Returns 1 on success, 0 otherwise.
int bind()
int bind(string dn, string password)
int bind(string dn, string password, int version)
Authenticates connection to the direcory.
First form uses default value previously entered in create.
Second form uses value from parameters:
The distinguished name (DN) of an entry aginst which will be made authentication.
Password used for authentication.
Third form allows specify the version of LDAP protocol used by connection to the LDAP server.
The desired protocol version (current 2 or 3).
Defaults to 3 if zero or left out.
Returns 1 on success, 0 otherwise.
Only simple authentication type is implemented. So be warned clear text passwords are sent to the directory server.
The API change: the returning code was changed in Pike 7.3+ to follow his logic better.
int unbind()
Unbinds from the directory and close the connection.
int delete(string dn)
Deletes entry from the LDAP server.
The distinguished name of deleted entry.
Returns 1 on success, 0 otherwise.
The API change: the returning code was changed in Pike 7.3+ to follow his logic better.
int compare(string dn, string attr, string value)
Compares an attribute value with one in the directory.
The distinguished name of the entry.
The type (aka name) of the attribute to compare.
The value to compare with. It's UTF-8 encoded automatically if the attribute syntax specifies that.
Returns 1 if at least one of the values for the
attribute in the directory is equal to value , 0 if
it didn't match or there was some error (use error_number to
find out).
This function has changed arguments since version 7.6. From 7.3 to 7.6 it was effectively useless since it always returned true.
The equality matching rule for the attribute governs the comparison. There are attributes where the assertion syntax used here isn't the same as the attribute value syntax.
int add(string dn, mapping(string:array(string)) attrs)
The Add Operation allows a client to request the addition of an entry into the directory
The Distinguished Name of the entry to be added.
The mapping of attributes and their values that make up the content of the entry being added. Values that are sent UTF-8 encoded according the the attribute syntaxes are encoded automatically.
Returns 1 on success, 0 otherwise.
The API change: the returning code was changed in Pike 7.3+ to follow his logic better.
array(string) get_root_dse_attr(string attr)
Returns the value of an attribute in the root DSE (DSA-Specific Entry) of the bound server. The result is cached. A working connection is assumed.
The return value is an array of the attribute values, which have been UTF-8 decoded where appropriate.
Don't be destructive on the returned array.
This function intentionally does not try to simplify the return values for single-valued attributes (c.f. Protocols.LDAP.SEARCH_MULTIVAL_ARRAYS_ONLY ). That since (at least) Microsoft AD has a bunch of attributes in the root DSE that they don't bother to provide schema entries for. The return value format wouldn't be reliable if they suddenly change that.
multiset(string) get_supported_controls()
Returns a multiset containing the controls supported by the server. They are returned as object identifiers on string form. A working connection is assumed.
search
object make_filter(string filter)
Returns the ASN1 object parsed from the given filter. This is a wrapper for Protocols.LDAP.make_filter which parses the filter with the LDAP protocol version currently in use by this connection.
If there's a parse error in the filter then a Protocols.LDAP.FilterError is thrown as from Protocols.LDAP.make_filter .
object get_cached_filter(string filter)
This is a wrapper for Protocols.LDAP.get_cached_filter which passes the LDAP protocol version currently in use by this connection.
If there's a parse error in the filter then a Protocols.LDAP.FilterError is thrown as from Protocols.LDAP.make_filter .
object get_default_filter()
Returns the ASN1 object parsed from the filter specified in the LDAP URL, or zero if the URL doesn't specify any filter.
If there's a parse error in the filter then a Protocols.LDAP.FilterError is thrown as from Protocols.LDAP.make_filter .
result|int search(string|object|void filter, array(string)|void attrs, int|void attrsonly, void|mapping(string:array(int|string)) controls, void|int flags)
Search LDAP directory.
Search filter to override the one from the LDAP URL. It's either a string with the format specified in RFC 2254, or an object returned by Protocols.LDAP.make_filter .
The array of attribute names which will be returned by server for every entry.
This flag causes server return only the attribute types (aka names) but not their values. The values will instead be empty arrays or - if Protocols.LDAP.SEARCH_MULTIVAL_ARRAYS_ONLY is given - zeroes for single-valued attributes.
Extra controls to send in the search query, to modify how the server executes the search in various ways. The value is a mapping with an entry for each control.
| |||||||||
Bitfield with flags to control various behavior at the client
side of the search operation. See the
Protocol.LDAP.SEARCH_* constants for details.
Returns object LDAP.client.result on success, 0
otherwise.
The API change: the returning code was changed in Pike 7.3+ to follow his logic better.
result , result.fetch , read , get_supported_controls , Protocols.LDAP.ldap_encode_string , Protocols.LDAP.make_filter
mapping(string:string|array(string)) read(string object_name, void|string filter, void|array(string) attrs, void|int attrsonly, void|mapping(string:array(int|string)) controls, void|int flags)
Reads a specified object in the LDAP server. object_name is the distinguished name for the object. The rest of the arguments are the same as to search .
The default filter and attributes that might have been set in the
LDAP URL doesn't affect this call. If filter isn't set then
"(objectClass=*)" is used.
Returns a mapping of the requested attributes. It has the same form as the response from result.fetch .
search
string|array(string) read_attr(string object_name, string attr, void|string filter, void|mapping(string:array(int|string)) controls)
Reads a specified attribute of a specified object in the LDAP server. object_name is the distinguished name of the object and attr is the attribute. The rest of the arguments are the same as to search .
The default filter that might have been set in the LDAP URL
doesn't affect this call. If filter isn't set then
"(objectClass=*)" is used.
For single-valued attributes, the value is returned as a string. For multivalued attributes, the value is returned as an array of strings. Returns zero if there was an error.
read , get_root_dse_attr
int get_protocol_version()
Return the LDAP protocol version in use.
string set_basedn(string base_dn)
Sets the base DN for searches using search and schema queries using get_attr_type_descr .
For compatibility, the old base DN is returned. However, if LDAPv3 is used, the value is UTF-8 encoded. Use get_basedn separately instead.
string get_basedn()
Returns the current base DN for searches using search and schema queries using get_attr_type_descr .
string get_bound_dn()
Returns the bind DN currently in use for the connection. Zero is returned if the connection isn't bound. The empty string is returned if the connection is in use but no bind DN has been given explicitly to bind .
string get_bind_password_hash()
Returns an MD5 hash of the password used for the bind operation, or zero if the connection isn't bound. If no password was given to bind then an empty string was sent as password, and the MD5 hash of that is therefore returned.
int set_scope(int|string scope)
Sets value of scope for search operation.
The value can be one of the SCOPE_* constants or a
string "base", "one" or "sub".
Returns the SCOPE_* constant for the old scope.
string get_scope()
Return the currently set scope as a string "base",
"one", or "sub".
int set_option(int opttype, int value)
LDAP_OPT_xxx
new value for option
int get_option(int opttype)
LDAP_OPT_xxx
mapping(string:mixed) get_parsed_url()
Returns a mapping containing the data parsed from the LDAP URL passed to create . The mapping has the same format as the return value from Protocols.LDAP.parse_ldap_url . Don't be destructive on the returned value.
int modifydn(string dn, string newrdn, int deleteoldrdn, string|void newsuperior)
The Modify DN Operation allows a client to change the leftmost (least significant) component of the name of an entry in the directory, or to move a subtree of entries to a new location in the directory.
DN of source object
RDN of destination
The parameter controls whether the old RDN attribute values are to be retained as attributes of the entry, or deleted from the entry.
If present, this is the Distinguished Name of the entry which becomes the immediate superior of the existing entry.
Returns 1 on success, 0 otherwise.
The API change: the returning code was changed in Pike 7.3+ to follow his logic better.
int modify(string dn, mapping(string:array(int(0..2)|string)) attropval)
The Modify Operation allows a client to request that a modification of an entry be performed on its behalf by a server.
The distinguished name of modified entry.
The mapping of attributes with requested operation and attribute's values.
attropval=([ attribute: ({operation, value1, value2, ...}) ])
Where operation is one of the following:
Add values listed to the given attribute, creating the attribute if necessary.
Delete values listed from the given attribute, removing the entire attribute if no values are listed, or if all current values of the attribute are listed for deletion.
Replace all existing values of the given attribute with the new values listed, creating the attribute if it did not already exist. A replace with no value will delete the entire attribute if it exists, and is ignored if the attribute does not exist.
Values that are sent UTF-8 encoded according the the attribute syntaxes are encoded automatically.
Returns 1 on success, 0 otherwise.
The API change: the returning code was changed in Pike 7.3+ to follow his logic better.
array|int get_referrals()
Gets referrals.
Returns array of referrals or 0.
mapping(string:mixed) parse_url(string ldapuri)
Compatibility alias for Protocols.LDAP.parse_ldap_url .
mapping(string:mixed) get_attr_type_descr(string attr, void|int standard_attrs)
Returns the attribute type description for the given attribute, which includes the name, object identifier, syntax, etc (see section 4.2 in RFC 2252 for details).
This might do a query to the server, but results are cached.
The name of the attribute. Might also be the object identifier on string form.
Flag that controls how the known standard attributes stored in Protocols.LDAP are to be used:
|
Returns a mapping where the indices are the terms that the
server has returned and the values are their values on string
form (dequoted and converted from UTF-8 as appropriate). Terms
without values get 1 as value in the mapping.
The mapping might contain the following members (all except
"oid" are optional):
|
There might be more fields for server extensions.
Zero is returned if the server didn't provide any attribute type description for attr .
It's the schema applicable at the base DN that is queried.
LDAPv3 is assumed.
| CLASS Protocols.LDAP.client.result |
Contains the result of a LDAP search.
LDAP.client.search , LDAP.client.result.fetch
object|int Protocols.LDAP.client.result(array(object) entries, int stuff, int flags)
You can't create instances of this object yourself. The only way to create it is via a search of a LDAP server.
int error_number()
Returns the error number in the search result.
error_string , server_error_string
string error_string()
Returns the description of the error in the search result. This is the error string from the server, or a standard error message corresponding to the error number if the server didn't provide any description.
server_error_string , error_number
string server_error_string()
Returns the error string from the server, or zero if the server didn't provide any.
error_string , error_number
int num_entries()
Returns the number of entries.
LDAP.client.result.count_entries
int count_entries()
Returns the number of entries from the current cursor position to the end of the list.
LDAP.client.result.first , LDAP.client.result.next
ResultEntry fetch(int|void idx)
Returns the current entry pointed to by the cursor.
This optional argument can be used for direct access to an entry other than the one currently pointed to by the cursor.
The return value is a mapping describing the entry:
|
Zero is returned if the cursor is outside the valid range of entries.
Unless Protocols.LDAP.SEARCH_RETURN_DECODE_ERRORS was given to search , a Locale.Charset.DecodeError is thrown if there is an error decoding the DN or any attribute value.
It's undefined whether or not destructive operations on the returned mapping will affect future fetch calls for the same entry.
In Pike 7.6 and earlier, the special "dn" entry was
incorrectly returned in UTF-8 encoded form for LDAPv3
connections.
fetch_all
string|Locale.Charset.DecodeError get_dn()
Returns distinguished name (DN) of the current entry in the
result list. Note that this is the same as getting the
"dn" field from the return value from fetch .
In Pike 7.6 and earlier, this field was incorrectly returned in UTF-8 encoded form for LDAPv3 connections.
void first()
Initialized the result cursor to the first entry in the result list.
LDAP.client.result.next
int next()
Moves the result cursor to the next entry in the result list. Returns number of remained entries in the result list. Returns 0 at the end.
LDAP.client.result.next
array(ResultEntry) fetch_all()
Convenience function to fetch all entries at once. The cursor isn't affected.
Returns an array where each element is the entry from the result. Don't be destructive on the returned value.
Unless Protocols.LDAP.SEARCH_RETURN_DECODE_ERRORS was given to search , a Locale.Charset.DecodeError is thrown if there is an error decoding the DN or any attribute value.
fetch
| CLASS Protocols.LDAP.FilterError |
Error object thrown by make_filter for parse errors.
constant Protocols.LDAP.FilterError.is_ldap_filter_error
Recognition constant.
| CLASS Protocols.LDAP.protocol |
int error_number()
Returns the error number from the last transaction. If the error
is LDAP_SERVER_DOWN then there was a socket error, and the
I/O error number can be retrieved using
ldapfd ->errno().
error_string , server_error_string
string error_string()
Returns the description of the error from the last transaction. This is the error string from the server, or a standard error message corresponding to the error number if the server didn't provide any description.
If error_number returns LDAP_SERVER_DOWN then this is the strerror message corresponding to the I/O error for the connection.
server_error_string , error_number
string server_error_string()
Returns the error string from the server, or zero if the server didn't provide any.
error_string , error_number
int get_last_io_time()
Returns when I/O was made last. Useful to find out whether it's safe to continue using a connection that has been idle for some time.
| Module Protocols.SNMP |
SNMPv1 and v2c
constant Protocols.SNMP.ERROR_TOOBIG
Error tooBig
constant Protocols.SNMP.ERROR_NOERROR
Error noError
constant Protocols.SNMP.ERROR_NOSUCHNAME
Error noSuchName
constant Protocols.SNMP.ERROR_BADVALUE
Error badValue
constant Protocols.SNMP.ERROR_READONLY
Error readOnly
constant Protocols.SNMP.ERROR_GENERROR
Error genError
constant Protocols.SNMP.REQUEST_GET
PDU type Get
constant Protocols.SNMP.REQUEST_GETNEXT
PDU type GetNext
constant Protocols.SNMP.REQUEST_SET
PDU type Set
constant Protocols.SNMP.REQUEST_GET_RESPONSE
PDU type GetResponse
constant Protocols.SNMP.REQUEST_TRAP
PDU type Trap
| CLASS Protocols.SNMP.protocol |
SNMP protocol implementation for Pike
RFCs:
implemented (yet): 1155-7 : v1
1901-4 : v2/community (Bulk ops aren't implemented!)
planned: 2742 : agentX
2570 : v3 description
inherit Stdio.UDP : snmp
int Protocols.SNMP.protocol.snmp_version
SNMP version
currently version 1 and 2 are supported.
string Protocols.SNMP.protocol.snmp_community
SNMP community string
should be set to the appropriate SNMP community before sending a request.
Set to "public" by default.
void Protocols.SNMP.protocol(int|void rem_port, string|void rem_addr, int|void loc_port, string|void loc_addr)
create a new SNMP protocol object
remote address and UDP port (optional)
local address and UDP port (optional)
mapping readmsg(int|float|void timeout)
return the whole SNMP message in raw format
mapping decode_asn1_msg(mapping rawd)
decode ASN1 data, if garbaged ignore it
void to_pool(mapping rawd)
decode raw pdu message and place in message pool
mapping readmsg_from_pool(int msgid)
read decoded message from pool
int get_request(array(string) varlist, string|void rem_addr, int|void rem_port)
GetRequest-PDU call
an array of OIDs to GET
remote address an UDP port to send request to (optional)
request ID
int get_response(mapping varlist, mapping origdata, int|void errcode, int|void erridx)
GetResponse-PDU call
a mapping containing data to return
| |||||||||||||||||||||||||||
original received decoded pdu that this response corresponds to
error code
error index
request ID
int get_nextrequest(array(string) varlist, string|void rem_addr, int|void rem_port)
GetNextRequest-PDU call
an array of OIDs to GET
remote address an UDP port to send request to (optional)
request ID
int set_request(mapping varlist, string|void rem_addr, int|void rem_port)
SetRequest-PDU call
a mapping of OIDs to SET
| |||||||||||||||||||||||||||
remote address an UDP port to send request to (optional)
request ID
// set the value of 1.3.6.1.4.1.1882.2.1 to "blah". object s=Protocols.SNMP.protocol(); s->snmp_community="mysetcommunity"; mapping req=(["1.3.6.1.4.1.1882.2.1": ({"str", "blah"})]); int id=s->set_request(req, "172.21.124.32");
int trap(mapping varlist, string oid, int type, int spectype, int ticks, string|void locip, string|void remaddr, int|void remport)
send an SNMP-v1 trap
a mapping of OIDs to include in trap
| |||||||||||||||||||||||||||
generic trap-type
specific trap-type
uptime
originating ip address of the trap
address and UDP to send trap to
request id
| CLASS Protocols.SNMP.agent |
A simple SNMP agent with support for SNMP Get requests
inherit "protocol"
void Protocols.SNMP.agent(int|void port, string|void addr)
create a new instance of the agent
the port number to listen for requests on
the address to bind to for listening
only one agent may be bound to a port at one time the agent does not currently support SMUX or AGENTX or other agent multiplexing protocols.
void set_threaded()
Run the agent event loop in a thread, if available.
void set_managers_only(int yesno)
enable manager access limits
1 to allow only managers to submit requests 0 to allow any host to submit requests
default setting allows all requests from all hosts
void set_get_communities(array communities)
set the valid community strings for Get requests
an array of valid Get communities
send an empty array to disable Get requests
void set_set_communities(array communities)
set the valid community strings for Set requests
an array of valid Set communities
send an empty array to disable Set requests
void set_managers(array managers)
set the valid manager list for requests
an array of valid management hosts
send an empty array to disable all requests
void set_set_oid_callback(string oid, function cb)
set the Set request callback function for an Object Identifier
the string object identifier, such as 1.3.6.1.4.1.132.2 or an asterisk (*) to serve as the handler for all requests for which a handler is specified.
the function to call when oid is requested by a manager the function should take 3 arguments: a string containing the requested oid, the desired value, and the body of the request as a mapping. The function should return an array containing 3 elements: The first is a boolean indicating success or failure. If success, the next 2 elements should be the SNMP data type of the result followed by the result itself. If failure, the next 2 elements should be the error-status such as Protocols.SNMP.ERROR_TOOBIG and the second is the error-index, if any.
there can be only one callback per object identifier. calling this function more than once with the same oid will result in the new callback replacing the existing one.
int clear_set_oid_callback(string oid)
clear the Set callback function for an Object Identifier
the string object identifier, such as 1.3.6.1.4.1.132.2 or an asterisk (*) to indicate the default handler.
1 if the callback existed, 0 otherwise
void|function get_set_oid_callback(string oid)
get the Set request callback function for an Object Identifier
the string object identifier, such as 1.3.6.1.4.1.132.2 or an asterisk (*) to indicate the default handler
the function associated with oid, if any
void set_get_oid_callback(string oid, function cb)
set the Get request callback function for an Object Identifier
the string object identifier, such as 1.3.6.1.4.1.132.2 or an asterisk (*) to serve as the handler for all requests for which a handler is specified.
the function to call when oid is requested by a manager the function should take 2 arguments: a string containing the requested oid and the body of the request as a mapping. The function should return an array containing 3 elements: The first is a boolean indicating success or failure. If success, the next 2 elements should be the SNMP data type of the result followed by the result itself. If failure, the next 2 elements should be the error-status such as Protocols.SNMP.ERROR_TOOBIG and the second is the error-index, if any.
there can be only one callback per object identifier. calling this function more than once with the same oid will result in the new callback replacing the existing one.
int clear_get_oid_callback(string oid)
clear the Get callback function for an Object Identifier
the string object identifier, such as 1.3.6.1.4.1.132.2 or an asterisk (*) to indicate the default handler.
1 if the callback existed, 0 otherwise
void|function get_get_oid_callback(string oid)
get the Get request callback function for an Object Identifier
the string object identifier, such as 1.3.6.1.4.1.132.2 or an asterisk (*) to indicate the default handler
the function associated with oid, if any
| Module Protocols.SMTP |
mapping(int:string) Protocols.SMTP.replycodes
A mapping(int:string) that maps SMTP return codes to english textual messages.
| CLASS Protocols.SMTP.Client |
inherit Protocol : Protocol
void Protocols.SMTP.Client()
void Protocols.SMTP.Client(Stdio.File server)
void Protocols.SMTP.Client(string server, void|int port)
Creates an SMTP mail client and connects it to the the server provided. The server parameter may either be a string witht the hostnam of the mail server, or it may be a file object acting as a mail server. If server is a string, than an optional port parameter may be provided. If no port parameter is provided, port 25 is assumed. If no parameters at all is provided the client will look up the mail host by searching for the DNS MX record.
Throws an exception if the client fails to connect to the mail server.
void send_message(string from, array(string) to, string body)
Sends a mail message from from to the mail addresses listed in to with the mail body body . The body should be a correctly formatted mail DATA block, e.g. produced by MIME.Message .
simple_mail
If the mail server returns any other return code than 200-399 an exception will be thrown.
void simple_mail(string to, string subject, string from, string msg)
Sends an e-mail. Wrapper function that uses send_message .
Some important headers are set to:
"Content-Type: text/plain; charset=iso-8859-1" and
"Content-Transfer-Encoding: 8bit". "Date:"
header isn't used at all.
If the mail server returns any other return code than 200-399 an exception will be thrown.
array(int|string) verify(string addr)
Verifies the mail address addr against the mail server.
| ||||||
Some mail servers does not answer truthfully to verfification queries in order to prevent spammers and others to gain information about the mail addresses present on the mail server.
If the mail server returns any other return code than 200-399 an exception will be thrown.
| CLASS Protocols.SMTP.Configuration |
Class to store configuration variable for the SMTP server
int Protocols.SMTP.Configuration.maxsize
Message max size
int Protocols.SMTP.Configuration.maxrcpt
Maximum number of recipients (default 1000)
int Protocols.SMTP.Configuration.checkdns
Verify sender domain for MX
int Protocols.SMTP.Configuration.checkemail
Lamme check email from validity
int Protocols.SMTP.Configuration.givedata
Give raw data and normal MIME data, if set to yes your cb_data function should take an extra string argument
| CLASS Protocols.SMTP.Connection |
The low-level class for the SMTP server
function(string:mixed) Protocols.SMTP.Connection.logfunction
This function is called whenever the SMTP server logs something. By default the log function is werror .
| CLASS Protocols.SMTP.Server |
The use of Protocols.SMTP.server is quite easy and allow you to design custom functions to process mail. This module does not handle mail storage nor relaying to other domains. So it is your job to provide mail storage and relay mails to other servers
void Protocols.SMTP.Server(array(string) _domains, void|int port, void|string ip, function _cb_mailfrom, function _cb_rcptto, function _cb_data)
Create a receiving SMTP server. It implements RFC 2821, 2822 and 1854.
Domains name this server relay, you need to provide at least one domain (the first one will be used for MAILER-DAEMON address). if you want to relay everything you can put a '*' after this first domain.
Port this server listen on
IP on which server listen
Mailfrom callback function, this function will be called when a client send a mail from command. This function must take a string as argument (corresponding to the sender's email) and return int corresponding to the SMTP code to output to the client. If you return an array the first element is the SMTP code and the second is the error string to display.
Same as cb_mailfrom but called when a client sends a rcpt to.
This function is called each time a client send a data content. It must have the following synopsis: int cb_data(object mime, string sender, array(string) recipients, void|string rawdata) object mime : the mime data object string sender : sender of the mail (from the mailfrom command) array(string) recipients : one or more recipients given by the rcpt to command return : SMTP code to output to the client. If you return an array the first element is the SMTP code and the second is the error string to display.
Here is an example of silly program that does nothing except outputing informations to stdout. int cb_mailfrom(string mail) { return 250; }
int cb_rcptto(string email) { // check the user's mailbox here return 250; }
int cb_data(object mime, string sender, array(string) recipients) { write(sprintf("smtpd: mailfrom=%s, to=%s, headers=%O\ndata=%s\n", sender, recipients * ", ", mime->headers, mime->getdata())); // check the data and deliver the mail here if(mime->body_parts) { foreach(mime->body_parts, object mpart) write("smtpd: mpart data = %O\n", mpart->getdata()); } return 250; }
int main(int argc, array(string) argv) { Protocols.SMTP.Server(({ "ece.fr" }), 2500, "127.0.0.1", cb_mailfrom, cb_rcptto, cb_data); return -1; }
| Module Protocols.Ident |
An implementation of the IDENT protocol, specified in RFC 931.
array(string) lookup(object fd)
Throws exception upon any error.
| CLASS Protocols.Ident.AsyncLookup |
void Protocols.Ident.AsyncLookup(object fd, function(array(string):void) cb, mixed ... args)
| Module Protocols.LPD |
| CLASS Protocols.LPD.client |
A client for communicating with printers and print spoolers that support the BSD lpd protocol (RFC 1179).
int set_job_type(string type)
Set the type of job to be sent to the printer to type. Valid types are: text, postscript and raw.
int set_job_name(string name)
Sets the name of the print job to name.
int start_queue(string queue)
Start the queue queue if not already printing.
Returns 0 if unable to connect, 1 otherwise.
string|int send_job(string queue, string job)
Send print job consisting of data job to printer queue.
Returns 1 if success, 0 otherwise.
int delete_job(string queue, int|void job)
Delete job job from printer queue.
Returns 1 on success, 0 otherwise.
string|int status(string queue)
Check the status of queue queue.
Returns 0 on failure, otherwise returns the status response from the printer.
void Protocols.LPD.client(string|void hostname, int|void portnum)
Create a new LPD client connection.
Contains the hostname or ipaddress of the print host. if not provided, defaults to localhost.
Contains the port the print host is listening on. if not provided, defaults to port 515, the RFC 1179 standard.
| Module Protocols.OBEX |
The IrDA® Object Exchange Protocol. OBEX is a protocol for sending and receiving binary objects to mobile devices using transports such as IR and Bluetooth.
constant Protocols.OBEX.SETPATH_BACKUP
A flag for the REQ_SETPATH command indicating that the parent directory should be selected
constant Protocols.OBEX.SETPATH_NOCREATE
A flag for the REQ_SETPATH command indicating that the selected directory should not be created if it doesn't exist
typedef mapping(HeaderIdentifier:string|int|array) Protocols.OBEX.Headers
A set of request or response headers. Each HI can be associated with either a single value (int or string, depending on the HI in question) or an array with multiple such values.
string encode_headers(Headers h)
Serialize a set of headers to wire format
split_headers()
Headers decode_headers(string h)
Deserialize a set of headers from wire format
array(string) split_headers(string h, int chunklen)
Given a set of headers in wire format, divide them into portions of no more than chunklen octets each (if possible). No individual header definition will be split into two portions.
| ENUM Protocols.OBEX.Request |
A request opcode, for use with the client.do_request() function.
constant Protocols.OBEX.REQ_CONNECT
Establish a new OBEX connection
constant Protocols.OBEX.REQ_DISCONNECT
Terminate an OBEX connection
constant Protocols.OBEX.REQ_PUT
Send an object to the mobile device
constant Protocols.OBEX.REQ_GET
Receive an object from the mobile devuce
constant Protocols.OBEX.REQ_SETPATH
Change the working directory
constant Protocols.OBEX.REQ_SESSION
Manage a session
constant Protocols.OBEX.REQ_ABORT
Abort the request currently being processed
constant Protocols.OBEX.REQ_FINAL
For REQ_PUT and REQ_GET requests, REQ_FINAL must be set for the request block containing the last portion of the headers. Other requests must be sent as a single block and have the REQ_FINAL bit encoded in their request opcode.
| ENUM Protocols.OBEX.HeaderIdentifier |
An identifier for a request or response header
constant Protocols.OBEX.HI_COUNT
Number of objects to transfer (used by REQ_CONNECT )
constant Protocols.OBEX.HI_NAME
Name of the object (string)
constant Protocols.OBEX.HI_TYPE
Type of the object (IANA media type)
constant Protocols.OBEX.HI_LENGTH
Length of the object transferred, in octets
constant Protocols.OBEX.HI_TIME
ISO 8601 timestamp (string)
constant Protocols.OBEX.HI_DESCRIPTION
Text description of the object
constant Protocols.OBEX.HI_TARGET
Name of service that operation is targeted to
constant Protocols.OBEX.HI_HTTP
Any HTTP 1.x header
constant Protocols.OBEX.HI_BODY
A chunk of the object body
constant Protocols.OBEX.HI_ENDOFBODY
The final chunk of the object body
constant Protocols.OBEX.HI_WHO
Identifies the OBEX application (string)
constant Protocols.OBEX.HI_CONNID
An identifier used for OBEX connection multiplexing
constant Protocols.OBEX.HI_APPPARAM
Extended application request & response information
constant Protocols.OBEX.HI_AUTHCHALL
Authentication digest-challenge
constant Protocols.OBEX.HI_AUTHRESP
Authentication digest-response
constant Protocols.OBEX.HI_CREATORID
Indicates the creator of an object
constant Protocols.OBEX.HI_WANUUID
Uniquely identifies the OBEX server
constant Protocols.OBEX.HI_OBJCLASS
OBEX object class of object
constant Protocols.OBEX.HI_SESSPARAM
Parameters used in session commands/responses
constant Protocols.OBEX.HI_SESSSEQNR
Sequence number used in each OBEX packet for reliability
| CLASS Protocols.OBEX.Client |
An OBEX client
ATclient
array(int|string) low_do_request(Request r, string data)
Perform a request/response exchange with the server. No interpretation is preformed of either the request or response data, they are just passed literally.
Request opcode
Raw request data
An array with the response information
| ||||||
do_request()
array(int|Headers) do_request(Request r, Headers|void headers, string|void extra_req)
Perform a request/response exchange with the server, including processing of headers and request splitting.
Request opcode
Request headers
Any request data that should appear before the headers, but after the opcode
An array with the response information
| ||||||
low_do_request() , do_abort() , do_put() , do_get() , do_setpath() , do_session()
array(int|Headers) do_abort(Headers|void headers)
Perform a REQ_ABORT request.
do_request()
array(int|Headers) do_put(string|Stdio.Stream data, Headers|void extra_headers)
Perform a REQ_PUT request.
Body data to send, or a stream to read the data from
Any additional headers to send (HI_LENGTH and HI_BODY are generated by this function)
do_get() , do_request()
array(int|Headers) do_get(Stdio.Stream data, Headers|void headers)
Perform a REQ_GET request.
A stream to write the body data to
Headers for the request
See do_request() . The Headers do not contain any HI_BODY headers, they are written to the data stream.
do_put() , do_request()
array(int|Headers) do_setpath(string path, int|void flags, Headers|void extra_headers)
Perform a REQ_SETPATH request.
The directory to set as current working directory
|
Logical or of zero or more of SETPATH_BACKUP and SETPATH_NOCREATE
Any additional request headers (the HI_NAME header is generated by this function)
do_request()
array(int|Headers) do_session(Headers|void headers)
Perform a REQ_SESSION request.
do_request()
int(0..1) connect()
Establish a new connection using the REQ_CONNECT opcode to negotiate transfer parameters
If the connection succeeds, 1 is returned. Otherwise, 0 is returned.
int(0..1) disconnect()
Terminate a connection using the REQ_DISCONNECT opcode
If the disconnection succeeds, 1 is returned. Otherwise, 0 is returned.
void Protocols.OBEX.Client(Stdio.Stream _con)
Initialize the client by establishing a connection to the server at the other end of the provided transport stream
A stream for writing requests and reading back responses. Typically this is some kind of serial port.
| CLASS Protocols.OBEX.ATClient |
An extension of the client which uses the AT*EOBEX modem command to enter OBEX mode. Use together with Sony Ericsson data cables.
inherit Client : Client
| Module Protocols.DNS |
Domain Name System RFC 1034, RFC 1035 and RFC 2308
void async_ip_to_host(string ip, function cb, mixed ... cba)
void async_host_to_ip(string host, function cb, mixed ... cba)
void async_get_mx_all(string host, function cb, mixed ... cba)
void async_get_mx(string host, function cb, mixed ... cba)
array gethostbyname(string host)
array gethostbyaddr(string host)
string get_mx(string host)
string get_primary_mx(string host)
| ENUM Protocols.DNS.ResourceClass |
Resource classes
constant Protocols.DNS.C_IN
Class Internet
constant Protocols.DNS.C_CS
Class CSNET (Obsolete)
constant Protocols.DNS.C_CH
Class CHAOS
constant Protocols.DNS.C_HS
Class Hesiod
constant Protocols.DNS.C_ANY
Class ANY
| ENUM Protocols.DNS.EntryType |
Entry types
constant Protocols.DNS.T_A
Type - host address
constant Protocols.DNS.T_NS
Type - authoritative name server
constant Protocols.DNS.T_MD
Type - mail destination (Obsolete - use MX)
constant Protocols.DNS.T_MF
Type - mail forwarder (Obsolete - use MX)
constant Protocols.DNS.T_CNAME
Type - canonical name for an alias
constant Protocols.DNS.T_SOA
Type - start of a zone of authority
constant Protocols.DNS.T_MB
Type - mailbox domain name (EXPERIMENTAL)
constant Protocols.DNS.T_MG
Type - mail group member (EXPERIMENTAL)
constant Protocols.DNS.T_MR
Type - mail rename domain name (EXPERIMENTAL)
constant Protocols.DNS.T_NULL
Type - null RR (EXPERIMENTAL)
constant Protocols.DNS.T_WKS
Type - well known service description
constant Protocols.DNS.T_PTR
Type - domain name pointer
constant Protocols.DNS.T_HINFO
Type - host information
constant Protocols.DNS.T_MINFO
Type - mailbox or mail list information
constant Protocols.DNS.T_MX
Type - mail exchange
constant Protocols.DNS.T_TXT
Type - text strings
constant Protocols.DNS.T_AAAA
Type - IPv6 address record (RFC 1886, deprecated)
constant Protocols.DNS.T_LOC
Type - Location Record (RFC 1876)
constant Protocols.DNS.T_SRV
Type - Service location record (RFC 2782)
constant Protocols.DNS.T_NAPTR
Type - NAPTR (RFC 3403)
constant Protocols.DNS.T_A6
Type - IPv6 address record (RFC 2874, incomplete support)
constant Protocols.DNS.T_SPF
Type - SPF - Sender Policy Framework (RFC 4408)
| CLASS Protocols.DNS.protocol |
Low level DNS protocol
string mkquery(string|mapping dnameorquery, int|void cl, int|void type)
create a DNS query PDU
record class such as Protocols.DNS.C_IN
query type such Protocols.DNS.T_A
data suitable for use with Protocols.DNS.client.do_sync_query
// generate a query PDU for a address lookup on the hostname pike.ida.liu.se string q=Protocols.DNS.protocol()->mkquery("pike.ida.liu.se", Protocols.DNS.C_IN, Protocols.DNS.T_A);
array decode_entries(string s, int num, array(int) next)
Decode a set of entries from an answer.
Encoded entries.
Number of entires in s .
Array with a single element containing the start position in s on entry and the continuation position on return.
Returns an array of mappings describing the decoded entires:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CLASS Protocols.DNS.server |
Implements a Domain Name Service (DNS) server.
inherit Stdio.UDP : udp
inherit protocol : protocol
mapping reply_query(mapping query, mapping udp_data)
Reply to a query (stub).
Parsed query.
Raw UDP data.
Overload this function to implement the proper lookup.
Returns 0 (zero) on failure, or a result mapping on success:
| ||||||||||||||||||
| CLASS Protocols.DNS.client |
Synchronous DNS client.
inherit protocol : protocol
void Protocols.DNS.client()
void Protocols.DNS.client(void|string|array server, void|int|array domain)
mapping do_sync_query(string s)
perform a syncronous query
result of Protocols.DNS.protocol.mkquery
mapping containing query result or 0 on failure/timeout
// perform a hostname lookup, results stored in r->an object d=Protocols.DNS.client(); mapping r=d->do_sync_query(d->mkquery("pike.ida.liu.se", C_IN, T_A));
array gethostbyname(string hostname)
Queries the host name from the default or given DNS server. The result is an array with three elements,
An array with the requested information about the specified host.
| ||||||||
Prior to Pike 7.7 this function only returned IPv4 addresses.
array getsrvbyname(string service, string protocol, string|void name)
Queries the service record (RFC 2782) from the default or given DNS server. The result is an array of arrays with the following six elements for each record. The array is sorted according to the priority of each record.
Each element of the array returned represents a service record. Each service record contains the following:
An array with the requested information about the specified service.
| ||||||||||
array gethostbyaddr(string hostip)
Queries the host name or ip from the default or given DNS server. The result is an array with three elements,
The requested data about the specified host.
| ||||||||
string get_primary_mx(string hostname)
Queries the primary mx for the host.
Returns the hostname of the primary mail exchanger.
| Module Protocols.LMTP |
| CLASS Protocols.LMTP.Server |
A LMTP server. It has been fairly well tested against Postfix client. Actually this module is only an extention to the SMTP server.
void Protocols.LMTP.Server(array(string) _domains, void|int port, void|string ip, function _cb_mailfrom, function _cb_rcptto, function _cb_data)
Create a receiving LMTP server. It implements RFC 2821, 2822, 2033 and 1854.
Domains name this server relay, you need to provide at least one domain (the first one will be used for MAILER-DAEMON address). if you want to relay everything you can put a '*' after this first domain.
Port this server listen on
IP on which server listen
Mailfrom callback function, this function will be called when a client send a mail from command. This function must take a string as argument (corresponding to the sender's email) and return int corresponding to the SMTP code to output to the client. If you return an array the first element is the SMTP code and the second is the error string to display.
Same as cb_mailfrom but called when a client sends a rcpt to.
This function is called for each recipient in the "rcpt to" command after the client sends the "data" command It must have the following synopsis: int|array cb_data(object mime, string sender, string recipient, void|string rawdata) object mime : the mime data object string sender : sender of the mail (from the mailfrom command) string recipient : one recipient given by one rcpt command. return : SMTP code to output to the client. If you return an array the first element is the SMTP code and the second is the error string to display. Note that to comply with LMTP protocol you must output a code each time this function is called.
Here is an example of silly program that does nothing except outputing informations to stdout. int cb_mailfrom(string mail) { return 250; }
int cb_rcptto(string email) { // check the user's mailbox here return 250; }
int cb_data(object mime, string sender, string recipient) { write(sprintf("smtpd: mailfrom=%s, to=%s, headers=%O\ndata=%s\n", sender, recipient, mime->headers, mime->getdata())); // check the data and deliver the mail here if(mime->body_parts) { { foreach(mime->body_parts, object mpart) write(sprintf("smtpd: mpart data = %O\n", mpart->getdata())); } return 250; }
int main(int argc, array(string) argv) { Protocols.LMTP.Server(({ "ece.fr" }), 2500, "127.0.0.1", cb_mailfrom, cb_rcptto, cb_data); return -1; }
| Module Protocols.Line |
| CLASS Protocols.Line.simple |
Simple nonblocking line-oriented I/O.
constant Protocols.Line.simple.line_separator
The sequence separating lines from eachother. "\r\n" by default.
function(string:void) Protocols.Line.simple.handle_data
If this variable has been set, multiple lines will be accumulated,
until a line with a single "." (period) is received.
handle_data() will then be called with the accumulated data
as the argument.
handle_data() is one-shot, ie it will be cleared when it is called.
The line with the single "." (period) will not be in the
accumulated data.
handle_command()
void handle_command(string line)
This function will be called once for every line that is received.
Overload this function as appropriate.
It will not be called if handle_data() has been set.
line will not contain the line separator.
handle_data()
void send(string s)
Queue some data to send.
handle_command() , handle_data() , disconnect()
void do_timeout()
This function is called when a timeout occurrs.
Overload this function as appropriate.
The default action is to shut down the connection immediately.
create() , touch_time()
void touch_time()
Reset the timeout timer.
create() , do_timeout()
string read_line()
Read a line from the input.
Returns 0 when more input is needed.
Returns the requested line otherwise.
The returned line will not contain the line separator.
handle_command() , line_separator
void read_callback(mixed ignored, string data)
Called when data has been received.
Overload as appropriate.
Calls the handle callbacks repeatedly until no more lines are available.
handle_data() , handle_command() , read_line()
ADT.Queue Protocols.Line.simple.send_q
Queue of data that is pending to send.
The elements in the queue are either strings with data to send,
or 0 (zero) which is the end of file marker. The connection
will be closed when the end of file marker is reached.
send() , disconnect()
void disconnect()
Disconnect the connection.
Pushes an end of file marker onto the send queue send_q .
Note that the actual closing of the connection is delayed until all data in the send queue has been sent.
No more data will be read from the other end after this function has been called.
void close_callback()
This function is called when the connection has been closed at the other end.
Overload this function as appropriate.
The default action is to shut down the connection on this side as well.
void Protocols.Line.simple(Stdio.File con, int|void timeout)
Create a simple nonblocking line-based protocol handler.
con is the connection.
timeout is an optional timeout in seconds after which the connection will be closed if there has been no data sent or received.
If timeout is 0 (zero), no timeout will be in effect.
touch_time() , do_timeout()
| CLASS Protocols.Line.smtp_style |
Nonblocking line-oriented I/O with support for sending SMTP-style codes.
inherit simple : simple
mapping(int:string|array(string)) Protocols.Line.smtp_style.errorcodes
Mapping from return-code to error-message.
Overload this constant as apropriate.
void send(int(100..999) code, array(string)|string|void lines)
Send an SMTP-style return-code.
code is an SMTP-style return-code.
If lines is omitted, errorcodes will be used to lookup an appropriate error-message.
If lines is a string, it will be split on "\n"
(newline), and the error-code interspersed as appropriate.
errorcodes
| CLASS Protocols.Line.imap_style |
Nonblocking line-oriented I/O with support for reading literals.
inherit simple : simple
int Protocols.Line.imap_style.literal_length
Length in bytes of the literal to read.
function(string:void) Protocols.Line.imap_style.handle_literal
If this variable has been set, literal_length bytes will be accumulated, and this function will be called with the resulting data.
handle_literal() is one-shot, ie it will be cleared when it is called.
function(string:void) Protocols.Line.imap_style.handle_line
This function will be called once for every line that is received.
This API is provided for backward compatibility; overload handle_command() instead.
Protocols.Line.simple()->handle_command()
void handle_command(string line)
Function called once for every received line.
void expect_literal(int length, function(string:void) callback)
Enter literal reading mode.
Sets literal_length and handle_literal() .
literal_length , handle_literal()
| Module Protocols.DNS_SD |
| CLASS Protocols.DNS_SD.Service |
This class provides an interface to DNS Service Discovery. The functionality of DNS-SD is described at <http://www.dns-sd.org/>.
Using the Proctocols.DNS_SD.Service class a Pike program can announce services, for example a web site or a database server, to computers on the local network.
When registering a service you need to provide the service name. service type, domain and port number. You can also optionally specify a TXT record. The contents of the TXT record varies between different services; for example, a web server can announce a path to a web page, and a printer spooler is able to list printer features such as color support or two-sided printing.
The service is registered on the network for as long as the instance of the Service class is valid.
inherit _Protocols_DNS_SD.Service : Service
void update_txt(string|array(string) txt)
Updates the TXT record for the service.
A TXT record with service-specific information. It can be given as a plain string or an array of property assignment strings. To remove an existing TXT record you give an empty string as the argument.
void Protocols.DNS_SD.Service(string name, string service, string domain, int port, void|string|array(string) txt)
Registers a service on the local network.
User-presentable name of the service.
Type of service on the form _type._protocol. Type is an identifier related to the service type. A list of registered service types can be found at http://http://www.dns-sd.org/ServiceTypes.html/. Protocol is normally tcp but udp is also a valid choice. For example, a web server would get a service of _http._tcp.
Domain name. Normally an empty string which the DNS-SD library will translate into local..
Port number for the service (e.g. 80 for a web site).
An optional TXT record with service-specific information. It can be given as a plain string or an array of property assignment strings. The TXT record can be changed later by calling update_txt in the object returned when you register the service.
object svc = Protocols.DNS_SD.Service( "Company Intranet Forum", // name "_http._tcp", // service type "", // domain (default) 80, // port ({ "path=/forum/" }) // TXT record );
| Module Protocols.NNTP |
| CLASS Protocols.NNTP.protocol |
NNTP protocol
inherit Stdio.FILE : sock
int readreturncode()
reads the server result code for last request used internally by command().
array(string) read_body_lines()
reads the message from the server as an array of lines
string readreturnbody()
reads the message from the server
void writebody(string s)
send the body of a message to the server.
int command(string cmd)
send a command to the server
the result code sent by the server
string get_response_message()
gets the result message supplied by the server for the last response
int failsafe_command(string cmd)
send a command and require an ok response (200 series). throws an error if the command result was not success.
string do_cmd_with_body(string cmd)
send a command that should return a message body.
the message body
| CLASS Protocols.NNTP.client |
An NNTP client
inherit protocol : protocol
array(Group) list_groups()
Returns a list of all active groups.
Group Protocols.NNTP.client.current_group
The current news group.
void set_group(Group o)
Sets the current news group to o .
Group go_to_group(string group)
Sets the current group to group .
string head(void|int|string x)
string body(void|int|string x)
string article(void|int|string x)
void Protocols.NNTP.client(string|void server)
| Module Protocols.TELNET |
Implements TELNET as described by RFC 764 and RFC 854
Also implements the Q method of TELNET option negotiation as specified by RFC 1143.
inherit TelnetCodes : TelnetCodes
inherit Telopts : Telopts
constant Protocols.TELNET.TELQUAL_IS
option is...
constant Protocols.TELNET.TELQUAL_SEND
send option
constant Protocols.TELNET.TELQUAL_INFO
ENVIRON: informational version of IS
constant Protocols.TELNET.TELQUAL_REPLY
AUTHENTICATION: client version of IS
constant Protocols.TELNET.TELQUAL_NAME
AUTHENTICATION: client version of IS
constant Protocols.TELNET.LFLOW_OFF
Disable remote flow control
constant Protocols.TELNET.LFLOW_ON
Enable remote flow control
constant Protocols.TELNET.LFLOW_RESTART_ANY
Restart output on any char
constant Protocols.TELNET.LFLOW_RESTART_XON
Restart output only on XON
constant Protocols.TELNET.AUTH_WHO_CLIENT
Client authenticating server
constant Protocols.TELNET.AUTH_WHO_SERVER
Server authenticating client
| CLASS Protocols.TELNET.TelnetCodes |
Table of IAC-codes.
constant Protocols.TELNET.TelnetCodes.IAC
interpret as command.
constant Protocols.TELNET.TelnetCodes.DONT
you are not to use option
constant Protocols.TELNET.TelnetCodes.DO
please, you use option
constant Protocols.TELNET.TelnetCodes.WONT
I won't use option
constant Protocols.TELNET.TelnetCodes.WILL
I will use option
constant Protocols.TELNET.TelnetCodes.SB
interpret as subnegotiation
constant Protocols.TELNET.TelnetCodes.GA
you may reverse the line
constant Protocols.TELNET.TelnetCodes.EL
erase the current line
constant Protocols.TELNET.TelnetCodes.EC
erase the current character
constant Protocols.TELNET.TelnetCodes.AYT
are you there
constant Protocols.TELNET.TelnetCodes.AO
abort output--but let prog finish
constant Protocols.TELNET.TelnetCodes.IP
interrupt process--permanently
constant Protocols.TELNET.TelnetCodes.BREAK
break
constant Protocols.TELNET.TelnetCodes.DM
data mark--for connect. cleaning
constant Protocols.TELNET.TelnetCodes.NOP
nop
constant Protocols.TELNET.TelnetCodes.SE
end sub negotiation
constant Protocols.TELNET.TelnetCodes.EOR
end of record (transparent mode)
constant Protocols.TELNET.TelnetCodes.ABORT
Abort process
constant Protocols.TELNET.TelnetCodes.SUSP
Suspend process
constant Protocols.TELNET.TelnetCodes.xEOF
End of file: EOF is already used...
constant Protocols.TELNET.TelnetCodes.SYNCH
for telfunc calls
| CLASS Protocols.TELNET.Telopts |
Table of TELNET options.
constant Protocols.TELNET.Telopts.TELOPT_BINARY
8-bit data path
constant Protocols.TELNET.Telopts.TELOPT_ECHO
echo
constant Protocols.TELNET.Telopts.TELOPT_RCP
prepare to reconnect
constant Protocols.TELNET.Telopts.TELOPT_SGA
suppress go ahead
constant Protocols.TELNET.Telopts.TELOPT_NAMS
approximate message size
constant Protocols.TELNET.Telopts.TELOPT_STATUS
give status
constant Protocols.TELNET.Telopts.TELOPT_TM
timing mark
constant Protocols.TELNET.Telopts.TELOPT_RCTE
remote controlled transmission and echo
constant Protocols.TELNET.Telopts.TELOPT_NAOL
negotiate about output line width
constant Protocols.TELNET.Telopts.TELOPT_NAOP
negotiate about output page size
constant Protocols.TELNET.Telopts.TELOPT_NAOCRD
negotiate about CR disposition
constant Protocols.TELNET.Telopts.TELOPT_NAOHTS
negotiate about horizontal tabstops
constant Protocols.TELNET.Telopts.TELOPT_NAOHTD
negotiate about horizontal tab disposition
constant Protocols.TELNET.Telopts.TELOPT_NAOFFD
negotiate about formfeed disposition
constant Protocols.TELNET.Telopts.TELOPT_NAOVTS
negotiate about vertical tab stops
constant Protocols.TELNET.Telopts.TELOPT_NAOVTD
negotiate about vertical tab disposition
constant Protocols.TELNET.Telopts.TELOPT_NAOLFD
negotiate about output LF disposition
constant Protocols.TELNET.Telopts.TELOPT_XASCII
extended ascic character set
constant Protocols.TELNET.Telopts.TELOPT_LOGOUT
force logout
constant Protocols.TELNET.Telopts.TELOPT_BM
byte macro
constant Protocols.TELNET.Telopts.TELOPT_DET
data entry terminal
constant Protocols.TELNET.Telopts.TELOPT_SUPDUP
supdup protocol
constant Protocols.TELNET.Telopts.TELOPT_SUPDUPOUTPUT
supdup output
constant Protocols.TELNET.Telopts.TELOPT_SNDLOC
send location
constant Protocols.TELNET.Telopts.TELOPT_TTYPE
terminal type
constant Protocols.TELNET.Telopts.TELOPT_EOR
end or record
constant Protocols.TELNET.Telopts.TELOPT_TUID
TACACS user identification
constant Protocols.TELNET.Telopts.TELOPT_OUTMRK
output marking
constant Protocols.TELNET.Telopts.TELOPT_TTYLOC
terminal location number
constant Protocols.TELNET.Telopts.TELOPT_3270REGIME
3270 regime
constant Protocols.TELNET.Telopts.TELOPT_X3PAD
X.3 PAD
constant Protocols.TELNET.Telopts.TELOPT_NAWS
window size
constant Protocols.TELNET.Telopts.TELOPT_TSPEED
terminal speed
constant Protocols.TELNET.Telopts.TELOPT_LFLOW
remote flow control
constant Protocols.TELNET.Telopts.TELOPT_LINEMODE
Linemode option
constant Protocols.TELNET.Telopts.TELOPT_XDISPLOC
X Display Location
constant Protocols.TELNET.Telopts.TELOPT_OLD_ENVIRON
Old - Environment variables
constant Protocols.TELNET.Telopts.TELOPT_AUTHENTICATION
Authenticate
constant Protocols.TELNET.Telopts.TELOPT_ENCRYPT
Encryption option
constant Protocols.TELNET.Telopts.TELOPT_NEW_ENVIRON
New - Environment variables
constant Protocols.TELNET.Telopts.TELOPT_EXOPL
extended-options-list
| CLASS Protocols.TELNET.protocol |
Implementation of the TELNET protocol.
protected object Protocols.TELNET.protocol.fd
The connection.
protected mapping Protocols.TELNET.protocol.cb
Mapping containing extra callbacks.
protected mixed Protocols.TELNET.protocol.id
Value to send to the callbacks.
protected function(mixed|void:string) Protocols.TELNET.protocol.write_cb
Write callback.
protected function(mixed:void) Protocols.TELNET.protocol.read_cb
Read callback.
protected function(mixed|void:void) Protocols.TELNET.protocol.close_cb
Close callback.
protected array(int) Protocols.TELNET.protocol.remote_options
protected array(int) Protocols.TELNET.protocol.local_options
Negotiation states of all WILL/WON'T options. See RFC 1143 for a description of the states.
protected string Protocols.TELNET.protocol.to_send
Data queued to be sent.
protected int Protocols.TELNET.protocol.done
Indicates that connection should be closed
protected int Protocols.TELNET.protocol.nonblocking_write
Tells if we have set the nonblocking write callback or not.
void enable_write()
Turns on the write callback if apropriate.
void disable_write()
Turns off the write callback if apropriate.
void write(string s)
Queues data to be sent to the other end of the connection.
String to send.
void write_raw(string s)
Queues raw data to be sent to the other end of the connection.
String with raw telnet data to send.
void close()
Closes the connetion neatly
void send_data()
Callback called when it is clear to send data over the connection. This function does the actual sending.
void send_synch()
Sends a TELNET synch command.
void send_DO(int option)
Starts negotiation to enable a TELNET option.
The option to enable.
void send_DONT(int option)
Starts negotiation to disable a TELNET option.
The option to disable.
protected int Protocols.TELNET.protocol.synch
Indicates whether we are in synch-mode or not.
void got_oob(mixed ignored, string s)
Callback called when Out-Of-Band data has been received.
The id from the connection.
The Out-Of-Band data received.
void call_read_cb(string data)
Calls read_cb() .
Specifically provided for overloading
void got_data(mixed ignored, string line)
Callback called when normal data has been received. This function also does most of the TELNET protocol parsing.
The id from the connection.
The received data.
void set_read_callback(function(mixed:void) r_cb)
function(mixed:void) query_read_callback()
void set_write_callback(function(mixed|void:string) w_cb)
Sets the callback to be called when it is clear to send.
The new write callback.
function(mixed|void:string) query_write_callback()
void set_close_callback(function(mixed|void:void) c_cb)
function(mixed|void:void) query_close_callback()
void setup()
Called when the initial setup is done.
Created specifically for overloading
void Protocols.TELNET.protocol(object f, function(mixed:void) r_cb, function(mixed|void:string) w_cb, function(mixed|void:void) c_cb, mapping callbacks, mixed|void new_id)
Creates a TELNET protocol handler, and sets its callbacks.
File to use for the connection.
Function to call when data has arrived.
Function to call when the send buffer is empty.
Function to call when the connection is closed.
Mapping with callbacks for the various TELNET commands.
Value to send to the various callbacks.
void set_nonblocking(function(mixed:void) r_cb, function(mixed|void:string) w_cb, function(mixed|void:void) c_cb)
Change the asynchronous I/O callbacks.
Function to call when data has arrived.
Function to call when the send buffer is empty.
Function to call when the connection is closed.
create()
| CLASS Protocols.TELNET.LineMode |
Line-oriented TELNET protocol handler.
inherit protocol : protocol
Based on the generic TELNET protocol handler.
void setup()
Perform the initial TELNET handshaking for LINEMODE.
| CLASS Protocols.TELNET.Readline |
Line-oriented TELNET protocol handler with Stdio.Readline support.
Implements the Stdio.NonblockingStream API.
inherit LineMode : LineMode
Based on the Line-oriented TELNET protocol handler.
Stdio.Readline Protocols.TELNET.Readline.readline
Stdio.Readline object handling the connection.
mapping(string:int) tcgetattr()
Get current terminal attributes.
Currently only the following attributes are supported:
|
Using this function currently bypasses the Readline layer.
Stdio.File()->tcgetattr()
int tcsetattr(mapping(string:int) options, string|void when)
Set terminal attributes.
Currently only the following attributes are supported:
|
Using this function currently bypasses the Readline layer.
Stdio.File()->tcsetattr()
void set_secret(int onoff)
Turn on/off echo mode.
void message(string s, void|int word_wrap)
Write a message.
void set_prompt(string s)
Set the readline prompt.
void close()
Close the connection.
void Protocols.TELNET.Readline(object f, function(mixed:void) r_cb, function(mixed|void:string) w_cb, function(mixed|void:void) c_cb, mapping callbacks, mixed|void new_id)
Creates a TELNET protocol handler, and sets its callbacks.
File to use for the connection.
Function to call when data has arrived.
Function to call when the send buffer is empty.
Function to call when the connection is closed.
Mapping with callbacks for the various TELNET commands.
Value to send to the various callbacks.
void set_nonblocking(function(mixed:void) r_cb, function(mixed|void:string) w_cb, function(mixed|void:void) c_cb)
Change the asynchronous I/O callbacks.
Function to call when data has arrived.
Function to call when the send buffer is empty.
Function to call when the connection is closed.
create()
void set_read_callback(function(mixed:void) r_cb)
function(mixed:void) query_read_callback()
void set_write_callback(function(mixed|void:string) w_cb)
function(mixed|void:string) query_write_callback()
void set_close_callback(function(mixed|void:void) c_cb)
function(mixed|void:void) query_close_callback()
void set_blocking()
void write(string s)
Queues data to be sent to the other end of the connection.
String to send.
| Module SSL |
| CLASS SSL.sslfile |
Interface similar to Stdio.File .
Handles blocking and nonblocking mode.
Handles callback mode in an arbitrary backend (also in blocking mode).
Read and write operations might each do both reading and writing. In callback mode that means that installing either a read or a write callback might install both internally. It also means that reading in one thread while writing in another doesn't work.
Callback changing operations like set_blocking and set_nonblocking aren't atomic.
Apart from the above, thread safety/atomicity characteristics are retained.
Blocking characterstics are retained for all functions.
is_open , connection init (create ) and close (close ) can do both reading and writing.
destroy attempts to close the stream properly by sending the close packet, but since it can't do blocking I/O it's not certain that it will succeed. The stream should therefore always be closed with an explicit close call.
Abrupt remote close without the proper handshake gets the errno System.EPIPE .
Objects do not contain cyclic references, so they are closed and destructed timely when dropped.
void SSL.sslfile(Stdio.File stream, SSL.context ctx, int|void is_client, int|void is_blocking)
Create a connection over stream , which should be an open socket or pipe. ctx is the SSL context. If is_client is set then a client-side connection is started, server-side otherwise. If is_blocking is set then the stream is initially set in blocking mode, nonblocking mode otherwise.
The backend used by stream is taken over and restored after the connection is closed (see close ). The callbacks and id in stream are overwritten.
mapping get_peer_certificate_info()
returns peer certificate information, if any.
array get_peer_certificates()
returns the peer certificate chain, if any.
int close(void|string how, void|int clean_close, void|int dont_throw)
Close the connection. Both the read and write ends are always
closed - the argument how is only for Stdio.File
compatibility and must be either "rw" or 0.
If clean_close is set then close messages are exchanged to shut down the SSL connection but not the underlying stream. It may then continue to be used for other communication afterwards. The default is to send a close message and then close the stream without waiting for a response.
I/O errors are normally thrown, but that can be turned off with dont_throw . In that case errno is set instead and 0 is returned. 1 is always returned otherwise. It's not an error to close an already closed connection.
In nonblocking mode the stream might not be closed right away and the backend might be used for a while afterwards. This means that if there's an I/O problem it might not be signalled immediately by close .
I/O errors from both reading and writing might occur in blocking mode.
If a clean close is requested and data following the close message is received at the same time, then this object will read it and has no way to undo that. That data can be retrieved with read afterwards.
Stdio.File shutdown()
Shut down the SSL connection without sending any more packets. The underlying stream is returned if the connection isn't shut down already and if a nonclean close hasn't been requested.
void destroy()
Try to close down the connection properly since it's customary to close files just by dropping them. No guarantee can be made that the close packet gets sent successfully though, because we can't risk blocking I/O here. You should call close explicitly.
string read(void|int length, void|int(0..1) not_all)
Read some (decrypted) data from the connection. Works like Stdio.File.read .
I/O errors from both reading and writing might occur in blocking mode.
int write(string|array(string) data, mixed ... args)
Write some (unencrypted) data to the connection. Works like Stdio.File.write except that this function often buffers some data internally, so there's no guarantee that all the consumed data has been successfully written to the stream in nonblocking mode. It keeps the internal buffering to a minimum, however.
This function returns zero if attempts are made to write data during the handshake phase and the mode is nonblocking.
I/O errors from both reading and writing might occur in blocking mode.
int renegotiate()
Renegotiate the connection by starting a new handshake. Note that the accept callback will be called again when the handshake is finished.
Returns zero if there are any I/O errors. errno() will give the details.
The read buffer is not cleared - a read() afterwards will
return data from both before and after the renegotiation.
Data in the write queue in nonblocking mode is not properly
written before resetting the connection. Do a blocking
write("") first to avoid problems with that.
void set_nonblocking(void|function(void|mixed:int) read, void|function(void|mixed:int) write, void|function(void|mixed:int) close, void|function(void|mixed:int) read_oob, void|function(void|mixed:int) write_oob, void|function(void|mixed:int) accept)
Set the stream in nonblocking mode, installing the specified callbacks. The alert callback isn't touched.
Prior to version 7.5.12, this function didn't set the accept callback.
read_oob and write_oob are currently ignored.
void set_nonblocking_keep_callbacks()
Set nonblocking mode like set_nonblocking , but don't alter any callbacks.
void set_blocking()
Set the stream in blocking mode. All but the alert callback are zapped.
There might be some data still waiting to be written to the stream. That will be written in the next blocking call, regardless what it is.
This function doesn't solve the case when the connection is used nonblocking in some backend thread and another thread switches it to blocking and starts using it. To solve that, put a call out in the backend from the other thread that switches it to blocking, and then wait until that call out has run.
Prior to version 7.5.12, this function didn't clear the accept callback.
void set_blocking_keep_callbacks()
Set blocking mode like set_blocking , but don't alter any callbacks.
int errno()
void set_alert_callback(function(object:void) alert)
Install a function that will be called when an alert packet is received. It doesn't affect the callback mode - it's called both from backends and from within normal function calls like read and write .
This object is part of a cyclic reference whenever this is set, just like setting any other callback.
function(object:void) query_alert_callback()
void set_accept_callback(function(void|object:int) accept)
Install a function that will be called when the handshake is finished and the connection is ready for use.
The callback function will be called with the sslfile object and the additional id arguments (set with set_id ).
Like the read, write and close callbacks, installing this callback implies callback mode, even after the handshake is done.
function(void|object:int) query_accept_callback()
void set_read_callback(function(void|mixed:int) read)
Install a function to be called when data is available.
function(void|mixed:int) query_read_callback()
void set_write_callback(function(void|mixed:int) write)
Install a function to be called when data can be written.
function(void|mixed:int) query_write_callback()
void set_close_callback(function(void|mixed:int) close)
Install a function to be called when the connection is closed, either normally or due to an error (use errno to retrieve it).
function(void|mixed:int) query_close_callback()
void set_id(mixed id)
mixed query_id()
void set_backend(Pike.Backend backend)
Set the backend used for the file callbacks.
Pike.Backend query_backend()
Return the backend used for the file callbacks.
string query_address(int|void arg)
int is_open()
Return nonzero if the stream currently is open, zero otherwise. This function does nonblocking I/O to check for a close packet in the input buffer.
Stdio.File query_stream()
Return the underlying stream.
Avoid any temptation to do
destruct(sslfile_obj->query_stream()). That almost
certainly creates more problems than it solves.
SSL.connection query_connection()
Return the SSL connection object.
SSL.context query_context()
Return the SSL context object.
| CLASS SSL.sslport |
Interface similar to Stdio.Port.
inherit Stdio.Port : socket
inherit .context : context
inherit ADT.Queue : accept_queue
| CLASS SSL.connection |
SSL packet layer. SSL.connection inherits SSL.handshake, and in addition to the state in the handshake super class, it contains the current read and write states, packet queues. This object is responsible for receiving and sending packets, processing handshake packets, and providing a clear text packages for some application.
inherit .handshake : handshake
inherit ADT.Queue : alert
inherit ADT.Queue : urgent
inherit ADT.Queue : application
void set_alert_callback(function(object:void) callback)
Called with alert object, sequence number of bad packet, and raw data as arguments, if a bad packet is received.
Can be used to support a fallback redirect https->http.
object recv_packet(string data)
Low-level receive handler. Returns a packet, an alert, or zero if more data is needed to get a complete packet.
void send_packet(object packet, int|void priority)
Queues a packet for write. Handshake and and change cipher must use the same priority, so must application data and close_notifies.
string|int to_write()
Extracts data from the packet queues. Returns a string of data to be written, "" if there are no pending packets, 1 of the connection is being closed politely, and -1 if the connection died unexpectedly.
This function is intended to be called from an i/o write callback.
void send_close()
Initiate close.
int send_streaming_data(string data)
Send an application data packet. If the data block is too large then as much as possible of the beginning of it is sent. The size of the sent data is returned.
string|int got_data(string|int s)
Main receive handler. Returns a string of received application data, or 1 if a close was received, or -1 if an error occured.
This function is intended to be called from an i/o read callback.
| CLASS SSL.alert |
Alert package.
inherit .packet : packet
void SSL.alert(int level, int description, int version, string|void message, mixed|void trace)
| CLASS SSL.https |
Dummy HTTPS server
inherit SSL.sslport : sslport
| CLASS SSL.packet |
SSL Record Layer. Handle formatting and parsing of packets.
| CLASS SSL.handshake |
SSL.handshake keeps the state relevant for SSL handshaking. This includes a pointer to a context object (which doesn't change), various buffers, a pointer to a session object (reuse or created as appropriate), and pending read and write states being negotiated.
Each connection will have two sets or read and write state: The current read and write states used for encryption, and pending read and write states to be taken into use when the current keyexchange handshake is finished.
array(int) SSL.handshake.client_cert_types
array(string) SSL.handshake.client_cert_distinguished_names
a few storage variables for client certificate handling on the client side. */
string SSL.handshake.client_random
string SSL.handshake.server_random
Random cookies, sent and received with the hello-messages.
int(-1..1) handle_handshake(int type, string data, string raw)
Do handshake processing. Type is one of HANDSHAKE_*, data is the contents of the packet, and raw is the raw packet received (needed for supporting SSLv2 hello messages).
This function returns 0 if hadshake is in progress, 1 if handshake is finished, and -1 if a fatal error occured. It uses the send_packet() function to transmit packets.
| CLASS SSL.session |
The most important information in a session object is a choice of encryption algorithms and a "master secret" created by keyexchange with a client. Each connection can either do a full key exchange to established a new session, or reuse a previously established session. That is why we have the session abstraction and the session cache. Each session is used by one or more connections, in sequence or simultaneously.
It is also possible to change to a new session in the middle of a connection.
string SSL.session.identity
Identifies the session to the server
int SSL.session.compression_algorithm
Always COMPRESSION_null.
int SSL.session.cipher_suite
Constant defining a choice of keyexchange, encryption and mac algorithm.
.Cipher.CipherSpec SSL.session.cipher_spec
Information about the encryption method derived from the cipher_suite.
int SSL.session.ke_method
Key exchange method, also derived from the cipher_suite.
string SSL.session.master_secret
48 byte secret shared between the client and the server. Used for deriving the actual keys.
mapping SSL.session.cert_data
information about the certificate in use by the peer, such as issuing authority, and verification status.
array(string) SSL.session.peer_certificate_chain
the peer certificate chain
array(string) SSL.session.certificate_chain
our certificate chain
void set_cipher_suite(int suite, int version)
Sets the proper authentication method and cipher specification for the given cipher suite and verison .
void set_compression_method(int compr)
Sets the compression method. Currently only COMPRESSION_null is supported.
array(string) generate_keys(string client_random, string server_random, array(int) version)
Generates keys appropriate for the SSL version given in version , based on the client_random and server_random .
| ||||||||||||||
array(.state) new_server_states(string client_random, string server_random, array(int) version)
Computes a new set of encryption states, derived from the client_random, server_random and master_secret strings.
| ||||||
array(.state) new_client_states(string client_random, string server_random, array(int) version)
Computes a new set of encryption states, derived from the client_random, server_random and master_secret strings.
| ||||||
| CLASS SSL.state |
A connection switches from one set of state objects to another, one or more times during its lifetime. Each state object handles a one-way stream of packets, and operates in either decryption or encryption mode.
object SSL.state.session
Information about the used algorithms.
.Cipher.MACAlgorithm SSL.state.mac
Message Authentication Code
.Cipher.CipherAlgorithm SSL.state.crypt
Encryption or decryption object.
Gmp.mpz SSL.state.seq_num
64-bit sequence number.
Alert|.packet decrypt_packet(.packet packet, int version)
Destructively decrypts a packet (including inflating and MAC-verification, if needed). On success, returns the decrypted packet. On failure, returns an alert packet. These cases are distinguished by looking at the is_alert attribute of the returned packet.
Alert|.packet encrypt_packet(.packet packet, int version)
Encrypts a packet (including deflating and MAC-generation).
| CLASS SSL.context |
Keeps the state that is shared by all SSL-connections for one server (or one port). It includes policy configuration, a server certificate, the server's private key(s), etc. It also includes the session cache.
Crypto.RSA SSL.context.rsa
The server's private key
Crypto.RSA SSL.context.client_rsa
The client's private key (used with client certificate authentication)
array(array(string)) SSL.context.client_certificates
An array of certificate chains a client may present to a server when client certificate authentication is requested.
function(.context:array(string)) SSL.context.client_certificate_selector
A function which will select an acceptable client certificate for presentation to a remote server. This function will receive the SSL context, an array of acceptable certificate types, and a list of DNs of acceptable certificate authorities. This function should return an array of strings containing a certificate chain, with the client certificate first, (and the root certificate last, if applicable.)
int SSL.context.auth_level
Policy for client authentication. One of SSL.Constants.AUTHLEVEL_none , SSL.Constants.AUTHLEVEL_ask and SSL.Constants.AUTHLEVEL_require .
void set_authorities(array(string) a)
Array of authorities that are accepted for client certificates. The server will only accept connections from clients whose certificate is signed by one of these authorities. The string is a DER-encoded certificate, which typically must be decoded using MIME.decode_base64 or Tools.PEM.Msg first.
Note that it is presumed that the issuer will also be trusted by the server. See trusted_issuers for details on specifying trusted issuers.
If empty, the server will accept any client certificate whose issuer is trusted by the server.
int SSL.context.require_trust
When set, require the chain to be known, even if the root is self signed.
Note that if set, and certificates are set to be verified, trusted issuers must be provided, or no connections will be accepted.
array(string) get_authorities()
Get the list of allowed authorities. See set_authorities .
void set_trusted_issuers(array(array(string)) i)
Sets the list of trusted certificate issuers.
An array of certificate chains whose root is self signed (ie a root issuer), and whose final certificate is an issuer that we trust. The root of the certificate should be first certificate in the chain. The string is a DER-encoded certificate, which typically must be decoded using MIME.decode_base64 or Tools.PEM.Msg first.
If this array is left empty, and the context is set to verify certificates, a certificate chain must have a root that is self signed.
array(array(string)) get_trusted_issuers()
Get the list of trusted issuers. See set_trusted_issuers .
int SSL.context.verify_certificates
Determines whether certificates presented by the peer are verified, or just accepted as being valid.
Crypto.RSA SSL.context.long_rsa
Crypto.RSA SSL.context.short_rsa
Temporary, non-certified, private keys, used with a server_key_exchange message. The rules are as follows:
If the negotiated cipher_suite has the "exportable" property, and short_rsa is not zero, send a server_key_exchange message with the (public part of) the short_rsa key.
If the negotiated cipher_suite does not have the exportable property, and long_rsa is not zero, send a server_key_exchange message with the (public part of) the long_rsa key.
Otherwise, dont send any server_key_exchange message.
Crypto.DSA SSL.context.dsa
Servers dsa key.
.Cipher.DHParameters SSL.context.dh_params
Parameters for dh keyexchange.
function(int:string) SSL.context.random
Used to generate random cookies for the hello-message. If we use the RSA keyexchange method, and this is a server, this random number generator is not used for generating the master_secret.
array(string) SSL.context.certificates
The server's certificate, or a chain of X509.v3 certificates, with the server's certificate first and root certificate last.
array(int) SSL.context.preferred_auth_methods
For client authentication. Used only if auth_level is AUTH_ask or AUTH_require.
array(int) SSL.context.preferred_suites
Cipher suites we want the server to support, best first.
void rsa_mode()
Set preferred_suites to RSA based methods.
void dhe_dss_mode()
Set preferred_suites to DSS based methods.
array(int) SSL.context.preferred_compressors
Always ({ COMPRESSION_null })
int SSL.context.use_cache
Non-zero to enable cahing of sessions
int SSL.context.session_lifetime
Sessions are removed from the cache when they are older than this limit (in seconds). Sessions are also removed from the cache if a connection using the session dies unexpectedly.
int SSL.context.max_sessions
Maximum number of sessions to keep in the cache.
.session lookup_session(string id)
Lookup a session identifier in the cache. Returns the corresponding session, or zero if it is not found or caching is disabled.
.session new_session()
Create a new session.
void record_session(.session s)
Add a session to the cache (if caching is enabled).
void purge_session(.session s)
Remove a session from the cache.
| Module SSL.Cipher |
Encryption and MAC algorithms used in SSL.
string prf(string secret, string label, string seed, int len)
ADT.struct rsa_sign(object context, string cookie, ADT.struct struct)
int(0..1) rsa_verify(object context, string cookie, ADT.struct struct, Gmp.mpz signature)
ADT.struct dsa_sign(object context, string cookie, ADT.struct struct)
ADT.struct anon_sign(object context, string cookie, ADT.struct struct)
| CLASS SSL.Cipher.CipherAlgorithm |
Cipher algorithm interface.
this_program set_encrypt_key(string)
this_program set_decrypt_key(string)
Set the key used for encryption/decryption, and enter encryption mode.
int(0..) block_size()
Return the block size for this crypto.
| CLASS SSL.Cipher.MACAlgorithm |
Message Authentication Code interface.
| CLASS SSL.Cipher.CipherSpec |
Cipher specification.
| CLASS SSL.Cipher.MACsha |
MAC using SHA.
string hash_raw(string data)
string hash(object packet, Gmp.mpz seq_num)
string hash_master(string data, string|void s)
void SSL.Cipher.MACsha(string|void s)
| CLASS SSL.Cipher.MACmd5 |
MAC using MD5.
inherit MACsha : MACsha
| CLASS SSL.Cipher.MAChmac_sha |
string hash(object packet, Gmp.mpz seq_num)
void SSL.Cipher.MAChmac_sha(string|void s)
| CLASS SSL.Cipher.MAChmac_md5 |
inherit MAChmac_sha : MAChmac_sha
void SSL.Cipher.MAChmac_md5(string|void s)
| CLASS SSL.Cipher.DES |
inherit Crypto.CBC : CBC
| CLASS SSL.Cipher.DES3 |
inherit Crypto.CBC : CBC
| CLASS SSL.Cipher.DHParameters |
Diffie-Hellman parameters.
Gmp.mpz SSL.Cipher.DHParameters.p
Gmp.mpz SSL.Cipher.DHParameters.g
Gmp.mpz SSL.Cipher.DHParameters.order
| Module SSL.Constants |
Protocol constants
| ENUM SSL.Constants.KeyExchangeType |
Key exchange methods.
constant SSL.Constants.KE_rsa
Rivest-Shamir-Adelman
constant SSL.Constants.KE_dh
Diffie-Hellman
| ENUM SSL.Constants.CompressionType |
Compression methods.
constant SSL.Constants.COMPRESSION_null
No compression.
| Module Web |
| CLASS Web.OWL |
Represents an RDF tuple set from an OWL perspective.
inherit .RDFS : RDFS
| CLASS Web.RDF |
Represents an RDF domain which can contain any number of complete statements.
RDFResource Web.RDF.rdf_Statement
Statement resource.
RDFResource Web.RDF.rdf_predicate
predicate resource.
RDFResource Web.RDF.rdf_subject
subject resource.
RDFResource Web.RDF.rdf_object
object resource.
RDFResource Web.RDF.rdf_type
type resource.
RDFResource Web.RDF.rdf_Seq
Seq resource.
RDFResource Web.RDF.rdf_first
first resource.
RDFResource Web.RDF.rdf_rest
rest resource.
RDFResource Web.RDF.rdf_nil
nil resource.
this_program add_statement(Resource|string|multiset(string) subj, Resource|string|multiset(string) pred, Resource|string|multiset(string) obj)
Adds a statement to the RDF set. If any argument is a string, it will be converted into a LiteralResource . If any argument is a multiset with one string in it, it will be converted into a URIResource .
Throws an exception if any argument couldn't be converted into a Resouce object.
int(0..1) has_statement(Resource subj, Resource pred, Resource obj)
Returns 1 if the RDF domain contains the relation {subj, pred, obj}, otherwise 0.
int(0..1) remove_statement(Resource subj, Resource pred, Resource obj)
Removes the relation from the RDF set. Returns 1 if the relation did exist in the RDF set.
Resource reify_low(Resource subj, Resource pred, Resource obj)
Reifies the statement { pred, subj, obj } and returns the resource that denotes the reified statement. There will not be any check to see if the unreified statement is already in the domain, making it possible to define the relation twice. The original statement will not be removed.
The subject of the reified statement.
Resource get_reify(Resource subj, Resource pred, Resource obj)
Returns a resource that is the subject of the reified statement {subj, pred, obj}, if such a resource exists in the RDF domain.
Resource reify(Resource subj, Resource pred, Resource obj)
Returns the result of get_reify , if any. Otherwise calls reify_low followed by remove_statement of the provided statement {subj, pred, obj}.
The subject of the reified statement.
int(0..1) dereify(Resource r)
Turns the reified statement r into a normal statement, if possible.
1 for success, 0 for failure.
int(0..) dereify_all()
Dereifies as many statements as possible. Returns the number of dereified statements.
array(Resource) get_properties()
Returns all properties in the domain, e.g. all resources that has been used as predicates.
mapping(Resource:mapping(Resource:array(Resource))) get_subject_map()
Returns a mapping with all the domains subject resources as indices and a mapping with that subjects predicates and objects as value.
URIResource get_resource(string uri)
Returns an RDF resource with the given URI as identifier, or zero.
URIResource make_resource(string uri)
Returns an RDF resource with the given URI as identifier, or if no such resrouce exists, creates it and returns it.
array(array(Resource)) find_statements(Resource|int(0..0) subj, Resource|int(0..0) pred, Resource|int(0..0) obj)
Returns an array with the statements that matches the given subject subj , predicate pred and object obj . Any and all of the resources may be zero to disregard from matching that part of the statement, i.e. find_statements(0,0,0) returns all statements in the domain.
An array with arrays of three elements.
| ||||||||
int(0..1) is_subject(Resource r)
Returns 1 if resource r is used as a subject, otherwise
0.
int(0..1) is_predicate(Resource r)
Returns 1 if resource r is used as a predicate,
otherwise 0.
int(0..1) is_object(Resource r)
Returns 1 if resource r is used as an object, otherwise
0.
string get_3_tuples()
Returns a 3-tuple serialization of all the statements in the RDF set.
string get_n_triples()
Returns an N-triples serialization of all the statements in the RDF set.
int parse_n_triples(string in)
Parses an N-triples string and adds the found statements to the RDF set. Returns the number of added relations.
The parser will throw errors on invalid N-triple input.
string decode_n_triple_string(string in)
Decodes a string that has been encoded for N-triples serialization.
Doesn't correctly decode backslashes that has been encoded with with \u- or \U-notation.
string encode_n_triple_string(string in)
Encodes a string for use as tring in N-triples serialization.
Web.RDF parse_xml(string|Parser.XML.NSTree.NSNode in, void|string base)
Adds the statements represented by the string or tree in to the RDF domain. If in is a tree the in-node should be the RDF node of the XML serialization. RDF documents take its default namespace from the URI of the document, so if the RDF document relies such ingenious mechanisms, pass the document URI in the base variable.
string get_xml(void|int no_optimize)
Serialize the RDF domain as an XML string.
If set, the XML serializer will refrain from doing most (size) optimizations of the output.
int _sizeof()
Returns the number of statements in the RDF domain.
Web.RDF `|(Web.RDF x)
Modifies the current object to create a union of the current object and the object x .
| CLASS Web.RDF.Resource |
Instances of this class represents resources as defined in RDF: All things being described by RDF expressions are called resources. A resource may be an entire Web page; such as the HTML document "http://www.w3.org/Overview.html" for example. A resource may be a part of a Web page; e.g. a specific HTML or XML element within the document source. A resource may also be a whole collection of pages; e.g. an entire Web site. A resource may also be an object that is not directly accessible via the Web; e.g. a printed book. This general resource is anonymous and has no URI or literal id.
Resources instantiated from this class should not be used in other RDF domain objects.
URIResource , LiteralResource
string get_n_triple_name()
Returns the nodes' N-triple serialized ID.
string get_3_tuple_name()
Returns the nodes' 3-tuple serialized ID.
| CLASS Web.RDF.LiteralResource |
Resource identified by literal.
inherit Resource : Resource
string Web.RDF.LiteralResource.datatype
Used to contain rdf:datatype value.
void Web.RDF.LiteralResource(string literal)
The resource will be identified by literal .
string get_xml()
Returns the literal as an XML string.
string get_literal()
Returns the literal string.
| CLASS Web.RDF.URIResource |
Resource identified by URI.
inherit Resource : Resource
void Web.RDF.URIResource(string uri)
Creates an URI resource with the uri as identifier.
Throws an error if another resource with the same URI already exists in the RDF domain.
string get_uri()
Returns the URI the resource references to.
string get_qname(void|string ns)
Returns the qualifying name, or zero.
string get_namespace()
Returns the namespace this resource URI references to.
| CLASS Web.RDF.RDFResource |
Resource used for RDF-technical reasons like reification.
inherit URIResource : URIResource
void Web.RDF.RDFResource(string rdf_id)
The resource will be identified by the identifier rdf_id
string get_qname(void|string ns)
Returns the qualifying name.
| Module Web.CGI |
| CLASS Web.CGI.Request |
Retrieves information about a CGI request from the environment and creates an object with the request information easily formatted.
mapping(string:array(string)) Web.CGI.Request.variables
mapping(string:int|string|array(string)) Web.CGI.Request.misc
string Web.CGI.Request.query
string Web.CGI.Request.rest_query
string Web.CGI.Request.data
multiset(string) Web.CGI.Request.prestate
If used with Roxen or Caudium webservers, this field will be populated with "prestate" information.
multiset(string) Web.CGI.Request.config
If used with Roxen or Caudium webservers, this field will be populated with "config" information.
multiset(string) Web.CGI.Request.supports
If used with Roxen or Caudium webservers, this field will be populated with "supports" information.
string Web.CGI.Request.remoteaddr
string Web.CGI.Request.remotehost
array(string) Web.CGI.Request.client
array(string) Web.CGI.Request.referer
multiset(string) Web.CGI.Request.pragma
mapping(string:string) Web.CGI.Request.cookies
string Web.CGI.Request.prot
string Web.CGI.Request.method
void Web.CGI.Request()
creates the request object. To use, create a Request object while running in a CGI environment. Environment variables will be parsed and inserted in the appropriate fields of the resulting object.
| Module Web.RSS |
Represents a RSS (RDF Site Summary) file.
Index parse_xml(string|Parser.XML.Tree.Node n, void|string base)
Returns an Index object, populated with the rss information given in the rss file n .
| CLASS Web.RSS.Thing |
The base class for the RSS resources.
void Web.RSS.Thing(string about, mapping attributes)
void Web.RSS.Thing(.RDF.Resource me)
Creates an RSS resource.
.RDF.Resource get_id()
Returns the RDF.Resource that identifies this RSS resource.
| CLASS Web.RSS.Image |
Represents an RSS image resource.
inherit Thing : Thing
string Web.RSS.Image.title
string Web.RSS.Image.url
string Web.RSS.Image.link
| CLASS Web.RSS.Item |
Represents an RSS item resource.
inherit Thing : Thing
string Web.RSS.Item.title
string Web.RSS.Item.link
string Web.RSS.Item.description
| CLASS Web.RSS.Textinput |
Represents an RSS textinput resource.
inherit Thing : Thing
string Web.RSS.Textinput.title
string Web.RSS.Textinput.description
string Web.RSS.Textinput.name
string Web.RSS.Textinput.link
| CLASS Web.RSS.Channel |
Represents an RSS channel.
inherit Thing : Thing
string Web.RSS.Channel.title
string Web.RSS.Channel.link
string Web.RSS.Channel.description
string|Standards.URI Web.RSS.Channel.image
string|Standards.URI Web.RSS.Channel.textinput
array(Item) Web.RSS.Channel.items
void add_item(Item i)
Adds the Item i to the Channel .
void remove_item(Item i)
Removes the Item i from the Channel .
| CLASS Web.RSS.Index |
Represents the top level of an RSS index.
.RDF Web.RSS.Index.rdf
The underlying RDF representation of the RSS index.
array(Channel) Web.RSS.Index.channels
The RSS channels.
array(Image) Web.RSS.Index.images
The RSS images.
array(Item) Web.RSS.Index.items
The RSS items.
array(Textinput) Web.RSS.Index.textinputs
The RSS textinputs.
void Web.RSS.Index(.RDF|void _rdf)
| Module Web.Crawler |
This module implements a generic web crawler.
Features:
Fully asynchronous operation (Several hundred simultaneous requests)
Supports the /robots.txt exclusion standard
Extensible
URI Queues
Allow/Deny rules
Configurable
Number of concurrent fetchers
Bits per second (bandwidth throttling)
Number of concurrent fetchers per host
Delay between fetches from the same host
Supports HTTP and HTTPS
| CLASS Web.Crawler.Stats |
Statistics.
int Web.Crawler.Stats.window_width
int Web.Crawler.Stats.granularityvoid Web.Crawler.Stats(int window_width, int granularity)
void bytes_read_callback(Standards.URI uri, int num_bytes_read)
This callback is called when data has arrived for a presently crawled URI, but no more often than once a second.
void close_callback(Standards.URI uri)
This callback is called whenever the crawling of a URI is finished or fails.
| CLASS Web.Crawler.Policy |
The crawler policy object.
int Web.Crawler.Policy.max_concurrent_fetchers
Maximum number of fetchers. Defaults to 100.
int Web.Crawler.Policy.max_bits_per_second_total
Maximum number of bits per second. Defaults to off (0).
int Web.Crawler.Policy.max_bits_per_second_per_host
Maximum number of bits per second, per host. Defaults to off (0).
int Web.Crawler.Policy.bandwidth_throttling_floating_window_width
Bandwidth throttling floating window width. Defaults to 30.
int Web.Crawler.Policy.max_concurrent_fetchers_per_host
Maximum concurrent fetchers per host. Defaults to 1.
int Web.Crawler.Policy.min_delay_per_host
Minimum delay per host. Defaults to 0.
| CLASS Web.Crawler.Queue |
A crawler queue. Does not need to be reentrant safe. The Crawler always runs in just one thread.
int|Standards.URI get()
Get the next URI to index. Returns -1 if there are no URIs to index at the time of the function call, with respect to bandwidth throttling and other limits. Returns 0 if there are no more URIs to index.
void put(string|array(string)|Standards.URI|array(Standards.URI) uri)
Put one or several URIs in the queue. Any URIs that were already present in the queue are silently disregarded.
| CLASS Web.Crawler.Rule |
Abstract rule class.
int check(string|Standards.URI uri)
| CLASS Web.Crawler.GlobRule |
A rule that uses glob expressions
a glob pattern that the rule will match against.
GlobRule("http://pike.ida.liu.se/*.xml");
inherit Rule : Rule
string Web.Crawler.GlobRule.patternvoid Web.Crawler.GlobRule(string pattern)
| CLASS Web.Crawler.RegexpRule |
A rule that uses Regexp expressions
inherit Rule : Rule
void Web.Crawler.RegexpRule(string re)
a string describing the Regexp expression
| CLASS Web.Crawler.RuleSet |
A set of rules
void add_rule(Rule rule)
add a rule to the ruleset
void remove_rule(Rule rule)
remove a rule from the ruleset
| CLASS Web.Crawler.MySQLQueue |
inherit Queue : Queue
void Web.Crawler.MySQLQueue(Stats _stats, Policy _policy, string _host, string _table, void|RuleSet _allow, void|RuleSet _deny)
| CLASS Web.Crawler.MemoryQueue |
Memory queue
inherit Queue : Queue
void Web.Crawler.MemoryQueue(Stats _stats, Policy _policy, RuleSet _allow, RuleSet _deny)
int|Standards.URI get()
Get the next URI to index. Returns -1 if there are no URIs to index at the time of the function call, with respect to bandwidth throttling, outstanding requests and other limits. Returns 0 if there are no more URIs to index.
void put(string|array(string)|Standards.URI|array(Standards.URI) uri)
Put one or several URIs in the queue. Any URIs that were already present in the queue are silently disregarded.
| CLASS Web.Crawler.ComplexQueue |
inherit Queue : Queue
Stats Web.Crawler.ComplexQueue.stats
Policy Web.Crawler.ComplexQueue.policyvoid Web.Crawler.ComplexQueue(Stats stats, Policy policy)
| CLASS Web.Crawler.Crawler |
void Web.Crawler.Crawler(Queue _queue, function _page_cb, function _error_cb, function _done_cb, function _prepare_cb, string|array(string)|Standards.URI|array(Standards.URI) start_uri, mixed ... _args)
function called when a page is retreived. Arguments are: Standards.URI uri, mixed data, mapping headers, mixed ... args. should return an array containing additional links found within data that will be analyzed for insertion into the crawler queue (assuming they are allowed by the allow/deny rulesets.
function called when an error is received from a server. Arguments are: Standards.URI real_uri, int status_code, mapping headers, mixed ... args. Returns void.
function called when crawl is complete. Accepts mixed ... args and returns void.
argument called before a uri is retrieved. may be used to alter the request. Argument is Standards.URI uri. Returns array with element 0 of Standards.URI uri, element 1 is a header mapping for the outgoing request.
location to start the crawl from.
optional arguments sent as the last argument to the callback functions.
| Module Graphics |
| Module Graphics.Graph |
inherit .create_pie : create_pie
mapping(string:mixed) check_mapping(mapping(string:mixed) diagram_data, string type)
This function sets all unset elements in diagram_data to its default value as well as performing some simple sanity checks. This function is called from within pie , bars , sumbars , line , norm and graph .
Image.Image pie(mapping(string:mixed) diagram_data)
Document this function
Image.Image bars(mapping(string:mixed) diagram_data)
Document this function
Image.Image sumbars(mapping(string:mixed) diagram_data)
Document this function
Image.Image line(mapping(string:mixed) diagram_data)
Document this function
Image.Image norm(mapping(string:mixed) diagram_data)
Document this function
Image.Image graph(mapping(string:mixed) diagram_data)
Document this function
| CLASS Graphics.Graph.create_bars |
Graph sub-module for drawing bars.
inherit .create_graph : create_graph
| CLASS Graphics.Graph.create_pie |
Graph sub-module for drawing pie-charts.
inherit .create_bars : create_bars
| CLASS Graphics.Graph.create_graph |
Graph sub-module for drawing graphs.
create_graph draws a graph but there are also some other functions used by create_pie and create_bars .
inherit .polyline : polyline
| CLASS Graphics.Graph.polyline |
Graph sub-module providing draw functions.
$Id: polyline.pike,v 1.7 2008/06/28 16:36:55 nilsson Exp $
| Module Tools |
| CLASS Tools.PV |
Display a image on the screen. Requires GTK.
inherit GTK.Window : Window
typedef Standards.URI|string|Image.Image|Image.Layer|array(Image.Layer) Tools.PV.PVImage
The image types accepted. If the image is a string, it is assumed to be a filename of a image that can be loaded with Image.load. This includes URLs.
void set_alpha_mode(AlphaMode m)
Set the alpha combining mode. m is one of Squares , Solid , None and AlphaOnly .
void set_alpha_colors(Image.Color.Color c1, Image.Color.Color|void c2)
Set the colors used for the alpha combination. c2 is only used for the Squares alpha mode.
set_alpha_mode()
Image.Image get_as_image(PVImage i)
Return the current image as a Image object, with the alpha combining done.
void set_image(PVImage i)
Change the image.
void scale(float factor)
Scale the image before display with the specified factor.
void save(string filename, string|void format)
Write the image to a file. If no format is specified, PNG is used. The alpha combination is done on the image before it's saved.
| ENUM Tools.PV.AlphaMode |
The alpha combination modes.
Use set_alpha_mode() to change the mode.
constant Tools.PV.Squares
Checkerboard pattern (default).
constant Tools.PV.Solid
Solid color.
constant Tools.PV.None
Ignore alpha.
constant Tools.PV.AlphaOnly
Only show the alpha channel (if any).
| Module Tools.AutoDoc |
| Module Tools.AutoDoc.ProcessXML |
inherit Parser.XML.Tree : Tree
inherit "module.pmod"
string extractXML(string filename, int|void pikeMode, string|void type, string|void name, array(string)|void parentModules)
This function extracts documentation from a file. The parameters type , name , and parentModules are used only when pikeMode != 0 and no C-style doc comments are present.
The file to extract from.
Non-zero if it is a Pike file. If the file contains style doc comments, C-mode is used despite pikeMode != 0.
"class", "module" or "namespace".
The name of the class/module/namespace.
The ancestors of the class/module/namespace.
// To extract doc for Foo.Bar.Ippa: string xml = extractXML("lib/modules/Foo.pmod/Bar.pmod/Ippa.pike", 1, "class", "Ippa", ({ "Foo", "Bar" }));
string moveImages(string docXMLFile, string imageSourceDir, string imageDestDir, int|void quiet)
Copy all images to canonical files in a flat directory.
The contents of the XML file. The XML file is the result of extraction from a single C or Pike file, for example the result of calling extractXML .
The directory that is the base of the relative paths to images. This should be the directory of the source file that was the input to extract the XML file.
The directory where the images should be copied.
Quiet operation.
The XML file contents (with decorated <image>-tags)
void mergeTrees(SimpleNode dest, SimpleNode source)
Puts all children of source into the tree dest , in their right place module-hierarchically. Used to merge the results of extractions of different Pike and C files.
The nodes source and dest are <class>, <module>, <namespace> or <autodoc> nodes that are identical in the sense that they represent the same module, class or namespace. Typically they both represent <autodoc> nodes.
After calling this method, any <class> or <module> nodes that have been marked with @appears or @belongs, are still in the wrong place in the tree, so handleAppears() (or postProcess() ) must be called on the whole documentation tree to relocate them once the tree has been fully merged.
void handleAppears(SimpleNode root)
Take care of all the @appears and @belongs directives everywhere, and rearranges the nodes in the tree accordingly
The root (<autodoc>) node of the documentation tree.
void postProcess(SimpleNode root)
Perform the last steps on a completed documentation tree.
Root <autodoc> node of the completed documentation tree.
Calls handleAppears() , cleanUndocumented() and resolveRefs() in turn.
handleAppears() , cleanUndocumented() , resolveRefs()
| Module Tools.Legal |
| Module Tools.Legal.License |
string get_text()
Returns all the licenses as a string, suitable for saving as a file.
| Module Tools.Legal.Copyright |
Contains functions and information to store and present copyright information about Pike and it's components.
void add(string what, array(string) holders)
Adds a copyright message for the copyright holders for the component what .
An error is thrown if the copyrighted component what is already in the list of copyrights.
string get_latest_pike()
Return the latest copyright holder of Pike.
mapping(string:array(string)) get_all()
Returns a mapping containing all the stored copyrights. The mapping maps component name to an array of copyright holders.
string get_text()
Returns the copyrights as a string, suitable for saving as a file.
| Module Tools.Shoot |
void _shoot(string id)
This function is called in the spawned pike, to perform the test but also to write some important data to stdout. id is the current test.
| CLASS Tools.Shoot.ExecTest |
The test call/result class. Instantiated with a test id and the test object itself.
string Tools.Shoot.ExecTest.id
Test Tools.Shoot.ExecTest.testvoid Tools.Shoot.ExecTest(string id, Test test)
int(0..1) run(int maximum_seconds, int maximum_runs, void|int silent)
This function runs the actual test, by spawning off a new pike and call it until at least one of these conditions: maximum_seconds has passed, or the number of runs is at least maximum_runs.
| CLASS Tools.Shoot.Test |
constant Tools.Shoot.Test.name
The name of the test.
void perform()
perform() is the function called in the tests, when it returns the test is complete.
| Module Tools.Standalone |
| CLASS Tools.Standalone.process_files |
Boilerplate to quickly whip up rsif-like hacks for creating file processing to churn away at stdin, or files and/or directories provided on the command line, recursively or not, creating backup files or not, listing the paths of all files action was taken for, and returning an exit status of how many files that would have been taken action on which could not be written back.
The all-round quickest way of making one of these tools is nicking the top portion of lib/modules/Tools.pmod/Standalone.pmod/process_files.pike or copying rsif.pike from the same directory. (The latter is 20 lines long, including docs, or about four lines of code.) Inherit process_files, and define your own version , description , usage , process , and, if you want arguments, want_args .
inherit Toole.Standalone.process_files : process_files
string Tools.Standalone.process_files.version
Your hack's version number. If you version control your file with cvs, we suggest you set the contents of this variable to something that that will automatically expand to a number for every new revision, for instance
string version = sprintf("%d.%d.%d",(int)__REAL_VERSION__,__REAL_MINOR__,__REAL_BUILD__);
string Tools.Standalone.process_files.description
One-liner that gets shown for this tool when running pike -x without additional options. (Assuming your tool resides in Standalone.pmod.) Does not include the name of the tool itself; just provide a nice, terse description, ending with a period for conformity.
string Tools.Standalone.process_files.usage
Long description of the purpose and usage of your tool, for --help and the case where not enough options are given on the command line. Its invocation mode (for instance "pike -x yourtool", when invoked that way) is prepended, and a list of available flags appended to this description.
int Tools.Standalone.process_files.want_args
The number of (mandatory) command-line options your hack needs and which your process callback wants (beside the input file). By default 0.
string process(string input, string ... args)
Gets called with the contents of a file (or stdin). Return your output, or 0 if you didn't do anything. args are the first want_args command-line options provided, before the list of files to process.
int(0..) Tools.Standalone.process_files.verbosity
0 in quiet mode, 1 by default, above = more output
int(0..1) Tools.Standalone.process_files.overwrite
0 to make backups, 1 to overwrite (default)
int(0..1) Tools.Standalone.process_files.recursive
1 to recurse into directories, 0 not to (default)
string Tools.Standalone.process_files.default_flag_docs
Flag docs to append to your usage description. Explains default options.
int(0..1) process_file(string path, string ... args)
Takes the path to a file and the first want_args command-line options provided, before the list of files to process. You might want to override this method if your tool needs to see file paths.
process_path
int(0..) process_path(string path, string ... args)
Takes the path to a file or directory and the first want_args first command-line options provided, before the list of files to process. You might want to override this method if your tool needs to see all paths.
process_file
int(0..) main(int argc, array(string) argv)
Base implementation of main program, handling basic flags and returning an exit status matching the number of failures during operation.
No easy way of adding your own command-line flags implemented yet. This would be a rather natural next feature to add, once somebody needs some.
| CLASS Tools.Standalone.pmar_install |
a prototype installer for prepackaged modules
note: portions of this code are highly inefficient (wrt tar filehandling). we assume that this will be used infrequently enough that this is not going to be a problem.
a package file is a tar file that contains the following structure:
ROOTDIR/ METADATA.TXT a file containing metadata about the package format: KEY=value, where values include: PLATFORM, in the form of os/processor (either can be "any") MODULE, the name of the module, in Module.Submodule format. VERSION, the version of this module. MODULE/ any files that need to be installed in the module directory MODREF/ ??? documentation suitable for inclusion in the modref INCLUDE/ ??? any pike language include files to be installed SCRIPTS/ standalone (no bundled dependencies) scripts used to perform custom actions they receive the installer object (this) and the System.Filesystem object of the package archive as arguments to the constructor. The method "run()" should perform the actual action. The run() method should return true or false to indicate success or failure. preinstall.pike postinstall.pike
| Module Tools.Monger |
| CLASS Tools.Monger.MongerDeveloper |
void set_auth(string _username, string _password)
set the username and password for accessing the remote repository.
void set_repository(string _repository)
specify an alternate repository location.
this should be a URL specifying the XMLRPC endpoint for the repository.
void set_default_repository()
sets the default repository location (modules.gotpike.org)
void set_directory(string _directory)
sets the monger directory to use for working and storing configurations.
void set_default_directory()
sets the default directory for working and storing configurations ($HOME/.monger)
int add_new_version(string module_name, string version, string changes, string license)
int update_version(string module_name, string version, string|void changes, string|void license)
int user_change_password(string|void _username, string _newpassword)
int user_change_email(string|void _username, string _newemail)
int set_version_active(string module_name, string version, int active)
int set_module_source(string module_name, string version, string filename)
int set_dependency(string module_name, string version, string dependency, string min_version, string max_version, int(0..1) required)
int delete_dependency(string module_name, string version, string dependency, string min_version, string max_version)
array get_dependencies(string module_name, string version)
| Module Tools.Testsuite |
array(int) run_script(string|array(string) pike_script)
Runs an external pike script from a testsuite. Use Tools.Testsuite.report_result in the script to report how many tests succeeded, failed, and were skipped. Those numbers are returned in the array from this function.
void report_result(int succeeded, int failed, void|int skipped)
Use this to report the number of successful, failed, and skipped tests in a script started using run_script .
| Module Tools.X509 |
constant Tools.X509.CERT_TOO_OLD
constant Tools.X509.CERT_TOO_NEW
constant Tools.X509.CERT_INVALID
constant Tools.X509.CERT_CHAIN_BROKEN
constant Tools.X509.CERT_ROOT_UNTRUSTED
constant Tools.X509.CERT_BAD_SIGNATURE
constant Tools.X509.CERT_UNAUTHORIZED_CA
UTC make_time(int t)
Creates a Standards.ASN1.Types.UTC object from the posix time t .
mapping(string:int) parse_time(UTC asn1)
Returns a mapping similar to that returned by gmtime
|
int(-1..1) time_compare(mapping(string:int) t1, mapping(string:int) t2)
Comparision function between two "date" mappings of the kind that parse_time returns.
Sequence make_tbs(object issuer, object algorithm, object subject, object keyinfo, object serial, int ttl, array extensions)
string make_selfsigned_dsa_certificate(Crypto.DSA dsa, int ttl, array name, array|void extensions)
string rsa_sign_digest(Crypto.RSA rsa, object digest_id, string digest)
int(0..1) rsa_verify_digest(Crypto.RSA rsa, object digest_id, string digest, string s)
string make_selfsigned_rsa_certificate(Crypto.RSA rsa, int ttl, array name, array|void extensions)
Verifier make_verifier(Object _keyinfo)
TBSCertificate decode_certificate(string|object cert)
TBSCertificate verify_certificate(string s, mapping authorities)
Decodes a certificate, checks the signature. Returns the TBSCertificate structure, or 0 if decoding or verification failes.
Authorities is a mapping from (DER-encoded) names to a verifiers.
This function allows self-signed certificates, and it doesn't check that names or extensions make sense.
mapping verify_certificate_chain(array(string) cert_chain, mapping authorities, int|void require_trust)
Decodes a certificate chain, checks the signatures. Verifies that the chain is unbroken, and that all certificates are in effect (time-wise.)
Returns a mapping with the following contents, depending on the verification of the certificate chain:
|
An array of certificates, with the relative-root last. Each certificate should be a DER-encoded certificate.
A mapping from (DER-encoded) names to verifiers.
Require that the certificate be traced to an authority, even if it is self signed.
See Standards.PKCS.Certificate.get_dn_string for converting the RDN to an X500 style string.
| CLASS Tools.X509.rsa_verifier |
inherit Verifier : Verifier
this_program init(string key)
int(0..1) verify(Sequence algorithm, string msg, string signature)
| CLASS Tools.X509.TBSCertificate |
string Tools.X509.TBSCertificate.der
int Tools.X509.TBSCertificate.version
Gmp.mpz Tools.X509.TBSCertificate.serial
Sequence Tools.X509.TBSCertificate.algorithm
Sequence Tools.X509.TBSCertificate.issuer
mapping Tools.X509.TBSCertificate.not_after
mapping Tools.X509.TBSCertificate.not_before
Sequence Tools.X509.TBSCertificate.subject
Verifier Tools.X509.TBSCertificate.public_key
BitString Tools.X509.TBSCertificate.issuer_id
optional
BitString Tools.X509.TBSCertificate.subject_id
optional
object Tools.X509.TBSCertificate.extensions
optional
this_program init(Object asn1)
| Module Tools.PEM |
Support for parsing PEM-style messages.
| CLASS Tools.PEM.EncapsulatedMsg |
string Tools.PEM.EncapsulatedMsg.boundary
contains the boundary string
string Tools.PEM.EncapsulatedMsg.body
contains the body of the message
mapping(string:string) Tools.PEM.EncapsulatedMsg.headers
void Tools.PEM.EncapsulatedMsg(string eb, string contents)
string decoded_body()
decodes a base 64 encoded message body
string get_boundary()
string canonical_body()
string to_string()
converts the message body and headers to the standard message format.
| CLASS Tools.PEM.RFC934 |
string Tools.PEM.RFC934.initial_text
string Tools.PEM.RFC934.final_text
string Tools.PEM.RFC934.final_boundary
array(EncapsulatedMsg) Tools.PEM.RFC934.encapsulated
void Tools.PEM.RFC934(string data)
decodes an RFC 934 encoded message.
string get_final_boundary()
string to_string()
| CLASS Tools.PEM.Msg |
Disassembles PGP and PEM style messages with parts separated by "-----BEGIN FOO-----" and "-----END FOO-----".
string Tools.PEM.Msg.initial_text
Contains any text preceeding the PEM message.
string Tools.PEM.Msg.final_text
Contains any text following the PEM message.
mapping(string:EncapsulatedMsg) Tools.PEM.Msg.parts
The decoded PEM message, as an array of EncapsulatedMsg objects indexed by message name, such as "CERTIFICATE".
void Tools.PEM.Msg(string s)
Creates a decoded PEM message
a string containing a PEM encoded message to be decoded.
| Module Tools.Hilfe |
string format_hr_time(int i)
Helper function that formats a time span in nanoseconds to something more human readable (ns, ms or s).
| CLASS Tools.Hilfe.Command |
Abstract class for Hilfe commands.
string help(string what)
Returns a one line description of the command. This help should be shorter than 54 characters.
string doc(string what, string with)
A more elaborate documentation of the command. This should be less than 68 characters per line.
void exec(Evaluator e, string line, array(string) words, array(string) tokens)
The actual command callback. Messages to the user should be written out by using the safe_write method in the Evaluator object.
| CLASS Tools.Hilfe.CommandReset |
Variable reset command. Put ___Hilfe->commands->reset = Tools.Hilfe.CommandReset(); in your .hilferc to have this command defined when you open Hilfe.
inherit Command : Command
| CLASS Tools.Hilfe.Expression |
Represents a Pike expression
void Tools.Hilfe.Expression(array(string) t)
An array of Pike tokens.
int _sizeof()
The number of non-whitespace tokens in the expression.
string `[](int f, void|int t)
Returns a token or a token range without whitespaces.
string `[]=(int f, string v)
Replaces a token with a new token.
int depth(int f)
Return the parenthesis depth at the given position.
int(0..1) in_sscanf(int f)
Returns 1 if the current position is within a sscanf expression.
string check_modifiers()
See if there are any forbidden modifiers used in the expression, e.g. "private int x;" is not valid inside Hilfe.
Returns an error message as a string if the expression
contains a forbidden modifier, otherwise 0.
string code()
Returns the expression verbatim.
int(-1..) endoftype(int(-1..) position)
Returns at which position the type declaration that begins at position position ends. A return value of -1 means that the token or tokens from position can not be a type declaration.
int(-1..) find_matching(string token, int(0..)|void pos)
Returns the position of the matching parenthesis of the given kind, starting from the given position. The position should be the position after the opening parenthesis, or later. Assuming balanced code. Returns -1 on failure.
int(0..1) is_block(int pos)
Is there a block starting at pos ?
mixed cast(string to)
An Expression object can be cast to an array or a string. In both forms all tokens, including white spaces will be returned.
| CLASS Tools.Hilfe.ParserState |
In every Hilfe object (Evaluator ) there is a ParserState object that manages the current state of the parser. Essentially tokens are entered in one end and complete expressions are outputted in the other. The parser object is accessible as ___Hilfe->state from Hilfe expressions.
void feed(array(string) tokens)
Feed more tokens into the state.
array(Expression) read()
Read out completed expressions. Returns an array where every element is an expression represented as an array of tokens.
void show_error(function(array(string)|string:int) w)
Prints out any error that might have occured while push_string was executed. The error will be printed with the print function w .
array(string) push_string(string line)
Sends the input line to Parser.Pike for tokenization, but keeps a state between each call to handle multiline /**/ comments and multiline #"" strings.
int datap()
Returns true if there is any waiting expression that can be fetched with read .
int(0..1) finishedp()
Are we in the middle of an expression. Used e.g. for changing the Hilfe prompt when entering multiline expressions.
void flush()
Clear the current state.
string status()
Returns the current parser state. Used by "dump state".
| CLASS Tools.Hilfe.HilfeHistory |
In every Hilfe object (Evaluator ) there is a HilfeHistory object that manages the result history. That history object is accessible both from __ and ___Hilfe->history in Hilfe expressions.
inherit ADT.History : History
| CLASS Tools.Hilfe.Evaluator |
This class implements the actual Hilfe interpreter. It is accessible as ___Hilfe from Hilfe expressions.
mapping(string:Command) Tools.Hilfe.Evaluator.commands
This mapping contains the available Hilfe commands, including the built in ones (dump, exit, help, new, quit), so it is possible to replace or remove them. The name of a command should be 10 characters or less.
ParserState Tools.Hilfe.Evaluator.state
Keeps the state, e.g. multiline input in process etc.
mapping(string:mixed) Tools.Hilfe.Evaluator.variables
The locally defined variables (name:value).
mapping(string:string) Tools.Hilfe.Evaluator.types
The types of the locally defined variables (name:type).
mapping(string:mixed) Tools.Hilfe.Evaluator.constants
The locally defined constants (name:value).
mapping(string:function) Tools.Hilfe.Evaluator.functions
The locally defined functions (name:value).
mapping(string:program) Tools.Hilfe.Evaluator.programs
The locally defined programs (name:value).
array(string) Tools.Hilfe.Evaluator.imports
The current imports.
array(string) Tools.Hilfe.Evaluator.inherits
The current inherits.
HilfeHistory Tools.Hilfe.Evaluator.history
The current result history.
array|object|function(string:int(0..)) Tools.Hilfe.Evaluator.write
The function to use when writing to the user.
void add_writer(object|function(string:int(0..)) new)
Adds another output function.
void remove_writer(object|function old)
Removes an output function.
int safe_write(array(string)|string in, mixed ... args)
An output method that shouldn't crash.
void add_input_hook(function|object new)
Adds a function to the input hook, making all user data be fed into the function.
remove_input_hook
void remove_input_hook(function|object old)
Removes a function from the input hook.
add_input_hook
void Tools.Hilfe.Evaluator()
void print_version()
Displays the current version of Hilfe.
void reset_evaluator()
Clears the current state, history and removes all locally defined variables, constants, functions and programs. Removes all imports and inherits. It does not reset the command mapping nor reevaluate the .hilferc file.
void add_input_line(string s)
Input a line of text into Hilfe. It checks if s is ".", in which case it calls state->flush(). Otherwise just calls add_buffer.
void add_buffer(string s)
Add buffer tokenizes the input string and determines if the new line is a Hilfe command. If not, it updates the current state with the new tokens and sends any and all complete expressions to evaluation in parse_expression .
string parse_expression(Expression expr)
Parses a Pike expression. Returns 0 if everything went well, or a string with an error message otherwise.
string Tools.Hilfe.Evaluator.last_compiled_expr
The last created wrapper in which an expression was evaluated.
int(0..) Tools.Hilfe.Evaluator.last_compile_time
The last compile time;
int(0..) Tools.Hilfe.Evaluator.last_eval_time
The last evaluation time;
int(0..1) Tools.Hilfe.Evaluator.strict_types
Strict types?
int(0..1) Tools.Hilfe.Evaluator.warnings
Show warnings?
int Tools.Hilfe.Evaluator.trace_level
The current trace level.
int Tools.Hilfe.Evaluator.assembler_debug_level
The current assembler debug level. Only available if Pike is compiled with RTL debug.
int Tools.Hilfe.Evaluator.compiler_trace_level
The current compiler trace level. Only available if Pike is compiled with RTL debug.
int Tools.Hilfe.Evaluator.debug_level
The current debug level. Only available if Pike is compiled with RTL debug.
int(0..1) Tools.Hilfe.Evaluator.last_else
Should an else expression be carried out?
void std_reswrite(function w, string sres, int num, mixed res)
The standard reswrite function.
function Tools.Hilfe.Evaluator.reswrite
The function used to write results. Gets as arguments in order: The safe_write function (function(string, mixed ...:int), the result as a string (string), the history entry number (int), the result (mixed), the compilation time (int) and the evaulation time (int). If the evaluated expression didn't return anything (e.g. a for loop) then 0 will be given as the result string.
object hilfe_compile(string f, void|string new_var)
Creates a wrapper and compiles the pike code f in it. If a new variable is compiled to be tested, its name should be given in new_var so that magically defined entities can be undefined and a warning printed.
void evaluate(string a, int(0..1) show_result)
Compiles the Pike code a and evaluates it by calling ___HilfeWrapper in the generated object. If show_result is set the result will be displayed and the result buffer updated with its value.
| CLASS Tools.Hilfe.StdinHilfe |
This is a wrapper containing a user interface to the Hilfe Evaluator so that it can actually be used. This wrapper uses the Stdio.Readline module to interface with the user. All input history is handled by that module, and as a consequence loading and saving .hilfe_history is handled in this class. Also .hilferc is handled by this class.
inherit Evaluator : Evaluator
Stdio.Readline Tools.Hilfe.StdinHilfe.readline
The readline object,
void save_history()
Saves the user input history, if possible, when called.
void Tools.Hilfe.StdinHilfe(void|array(string) init)
Any hilfe statements given in the init array will be executed once .hilferc has been executed.
| CLASS Tools.Hilfe.GenericHilfe |
inherit Evaluator : Evaluator
void Tools.Hilfe.GenericHilfe(Stdio.FILE in, Stdio.File out)
| CLASS Tools.Hilfe.GenericAsyncHilfe |
inherit Evaluator : Evaluator
void Tools.Hilfe.GenericAsyncHilfe(Stdio.File in, Stdio.File out)
| Module Tools.Install |
Common routines which are useful for various install scripts based on Pike.
array(string) features()
Return an array of enabled features.
Used by the master when given the option --features.
Tools.Standalone.features
string make_absolute_path(string path, string|void cwd)
| CLASS Tools.Install.ProgressBar |
A class keeping some methods and state to conveniently render ASCII progress bars to stdout.
void set_current(int _cur)
Change the amount of progress without updating on stdout.
void set_name(string _name)
Change the name of the progress bar without updating on stdout.
void set_phase(float _phase_base, float _phase_size)
int update(int increment)
Write the current look of the progressbar to stdout.
the number of increments closer to completion since last call
the length (in characters) of the line with the progressbar
void Tools.Install.ProgressBar(string name, int cur, int max, float|void phase_base, float|void phase_size)
The name (printed in the first 13 columns of the row)
How much progress has been made so far
The amount of progress signifying 100% done. Must be greater than zero.
| CLASS Tools.Install.Readline |
inherit Stdio.Readline : Readline
void trap_signal(int n)
string edit(mixed ... args)
string edit_filename(mixed ... args)
string edit_directory(mixed ... args)
string absolute_path(string path)
void set_cwd(string _cwd)
| Module Tools.sed |
edit commands supported:
<firstline>,<lastline><edit command>
^^ numeral (17) ^^
or relative (+17, -17)
or a search regexp (/regexp/)
or multiple (17/regexp//regexp/+2)
|
where line is numeral, first 'line'==0
string|array `()(string|array(string) commands, string|array(string) data, void|int suppress)
| Module Filesystem |
int parse_mode(int old, int|string mode)
FIXME: Document this function
program get_filesystem(string what)
FIXME: Document this function
function `()(void|string path)
FIXME: Document this function
| CLASS Filesystem.System |
Implements an abstraction of the normal filesystem.
inherit Filesystem.Base : Base
void Filesystem.System(void|string directory, void|string root, void|int fast, void|Filesystem.Base parent)
Instanciate a new object representing the filesystem.
The directory (in the real filesystem) that should become the root of the filesystemobject.
Internal
Internal
Internal
| CLASS Filesystem.Stat |
Describes the stat of a file
int(0..1) isfifo()
int(0..1) ischr()
int(0..1) isdir()
int(0..1) isblk()
int(0..1) isreg()
int(0..1) islnk()
int(0..1) issock()
int(0..1) isdoor()
Is the file a FIFO?
Is the file a character device?
Is the file (?) a directory?
Is the file a block device?
Is the file a regular file?
Is the file a link to some other file or directory?
Is the file a socket?
FIXME: Document this function.
1 if the file is of a specific type 0 if the file is not.
[set_type]
void set_type(string x)
Set a type for the stat-object.
This call doesnot change the filetype in the underlaying filesystem.
Type to set. Type is one of the following:
[isfifo], [ischr], [isdir], [isblk], [isreg], [islnk], [issock], [isdoor]
void attach_statarray(array(int) a)
Fills the stat-object with data from a Stdio.File.stat() call.
Stdio.File open(string mode)
Open the stated file within the filesystem
a [Stdio.File] object
[Stdio.File]
object cd()
Change to the stated directory.
the directory if the stated object was a directory, 0 otherwise.
string nice_date()
Returns the date of the stated object as cleartext.
| CLASS Filesystem.Base |
Baseclass that can be extended to create new filesystems. Is used by the Tar and System filesystem classes.
Base cd(string|void directory)
Change directory within the filesystem. Returns a new filesystem object with the given directory as cwd.
string cwd()
Returns the current working directory within the filesystem.
Base chroot(void|string directory)
Change the root of the filesystem.
Stat stat(string file, int|void lstat)
Return a stat-object for a file or a directory within the filesystem.
array(string) get_dir(void|string directory, void|string|array glob)
Returns an array of all files and directories within a given directory.
Directory where the search should be made within the filesystem. CWD is assumed if none (or 0) is given.
Return only files and dirs matching the glob (if given).
[get_stats]
array(Stat) get_stats(void|string directory, void|string|array glob)
Returns stat-objects for the files and directories matching the given glob within the given directory.
[get_dir]
Stdio.File open(string filename, string mode)
Open a file within the filesystem
A Stdio.File object.
int apply()
FIXME: Document this function
void chmod(string filename, int|string mode)
Change mode of a file or directory.
void chown(string filename, int|object owner, int|object group)
Change ownership of the file or directory
int mkdir(string directory, void|int|string mode)
Create a new directory
int rm(string filename)
Remove a file from the filesystem.
array find(void|function(Stat:int) mask, mixed ... extra)
FIXME: Document this function
| CLASS Filesystem.Traversion |
Iterator object that traverses a directory tree and returns files as values and paths as indices. Example that uses the iterator to create a really simple sort of make:
object i=Filesystem.Traversion("."); foreach(i; string dir; string file) { if(!has_suffix(file, ".c")) continue; file = dir+file; string ofile = file; ofile[-1]='o'; object s=file_stat(ofile); if(s && i->stat()->mtime<s->mtime) continue; // compile file }
float progress(void|float share)
Returns the current progress of the traversion as a value between 0.0 and 1.0. Note that this value isn't based on the number of files, but the directory structure.
void Filesystem.Traversion(string path, void|int(0..1) symlink, void|int(0..1) ignore_errors, void|function(array:array) sort_fun)
The root path from which to traverse.
Don't traverse symlink directories.
Ignore directories that can not be accessed.
Sort function to be applied to directory entries before traversing. Can also be a filter function.
Stdio.Stat stat()
Returns the stat for the current index-value-pair.
| Module Filesystem.Tar |
void Filesystem.Tar(string filename, void|Filesystem.Base parent, void|object file)
Filesystem which can be used to mount a Tar file.
The tar file to mount.
The parent filesystem. If non is given, the normal system filesystem is assumed. This allows mounting a TAR-file within a tarfile.
If specified, this should be an open file descriptor. This object could e.g. be a Stdio.File , Gz.File or Bz2.File object.
| Module Int |
int(0..1) parity(int(0..) value)
Returns the parity of the integer value . If the parity is odd 1 is returned. If it is even 0 is returned.
constant Int.NATIVE_MIN
constant Int.NATIVE_MAX
The limits for using the native representation of integers on the current architecture. Any integer that is outside this range uses a more complex and slower representation. Also, some builtin functions that don't expect very large integers might start to complain about invalid argument type when given values outside this range (they typically say something like "Expected integer, got object").
NATIVE_MIN is not greater than -2147483648
(-0x80000000).
NATIVE_MAX is not less than 2147483647
(0x7fffffff).
The size of the native integers can be controlled when Pike is
compiled with the configure flags --with-int-int,
--with-long-int, and --with-long-long-int. The
default is to use the longest available integer type that fits
inside a pointer, which typically means that it's 64 bit on "true"
64 bit architectures.
If Pike is compiled with the configure flag
--without-bignum (which is discouraged), then all
arithmetic operations will instead silently wrap around at these
limits.
int(0..65535) swap_word(int(0..65535) i)
Swaps the upper and lower byte in a word.
int(0..4294967295) swap_long(int(0..4294967295) i)
Swaps the upper and lower word in a longword, and the upper and lower bytes in the words. Simply put, the bytes are reversed.
Inf Int.inf
An infinite number.
| Module Process |
Process spawn_pike(array(string) argv, void|mapping(string:mixed) options)
Spawn a new pike process similar to the current.
Arguments for the new process.
Process creation options. See Process.Process for details.
Process.Process
mapping run(string|array(string) cmd, void|mapping modifiers)
Easy and lazy way of using Process.Process that runs a process and returns a mapping with the output and exit code without having to make sure you read nonblocking yourself.
Either a command line array, as the command_args argument to create_process() , or a string that will be splitted into a command line array by calling split_quoted_string() in an operating system dependant mode.
It takes all the modifiers Process.Process accepts, with the exception of stdout and stderr. Since the point of this function is to handle those you can not supply your own.
If modifiers->stdin is set to a string it will automaticly be
converted to a pipe that is fed to stdin of the started process.
Process.Process create_process
|
As the entire output of stderr and stdout is stored in the returned mapping it could potentially grow until memory runs out. It is therefor adviceable to set up rlimits if the output has a potientially be very large.
Process.run( ({ "ls", "-l" }) ); Process.run( ({ "ls", "-l" }), ([ "cwd":"/etc" ]) ); Process.run( "ls -l" ); Process.run( "awk -F: '{print $2}'", ([ "stdin":"foo:2\nbar:17\n" ]) );
int exec(string file, string ... foo)
string search_path(string command)
string sh_quote(string s)
array(string) split_quoted_string(string s, int(0..1)|void nt_mode)
Process spawn(string command, void|Stdio.Stream stdin, void|Stdio.Stream stdout, void|Stdio.Stream stderr, )
Spawns a process that executes command as a command shell
statement ("/bin/sh -c command " for Unix, "cmd /c
command " for Windows).
Stream objects to use as standard input, standard output and standard error, respectively, for the created process. The corresponding streams for this process are used for those that are left out.
Returns a Process.Process object for the created process.
system , popen
string popen(string command)
Executes command as a shell statement ("/bin/sh -c
command " for Unix, "cmd /c command " for Windows),
waits until it has finished and returns the result as a string.
system , spawn
Stdio.FILE popen(string command, string mode)
Open a "process" for reading or writing. The command is executed
as a shell statement ("/bin/sh -c command " for Unix,
"cmd /c command " for Windows). The parameter mode
should be one of the following letters:
|
system , spawn
int system(string command, void|Stdio.Stream stdin, void|Stdio.Stream stdout, void|Stdio.Stream stderr)
Executes command as a shell statement ("/bin/sh -c
command " for Unix, "cmd /c command " for Windows),
waits until it has finished and returns its return value.
Stream objects to use as standard input, standard output and standard error, respectively, for the created process. The corresponding streams for this process are used for those that are left out.
spawn , popen
| CLASS Process.Process |
Slightly polished version of create_process .
create_process
inherit create_process : create_process
void Process.Process(string|array(string) args, void|mapping(string:mixed) m)
Either a command line array, as the command_args argument to create_process() , or a string that will be splitted into a command line array by calling split_quoted_string() in an operating system dependant mode.
In addition to the modifiers that create_process accepts, this object also accepts
|
create_process , split_quoted_string
| CLASS Process.Spawn |
void Process.Spawn(string cmd, void|array(string) args, void|mapping(string:string) env, string|void cwd, void|array(Stdio.File|void) ownpipes, void|array(Stdio.File|void) fds_to_close)
int kill(int signal)
int wait()
| CLASS Process.create_process |
This is the recommended and most portable way to start processes in Pike. The process object is a pike abstraction of the running system process, with methods for various process housekeeping.
int wait()
Waits for the process to end.
|
TraceProcess()->wait()
int(-1..2) status()
Returns the status of the process:
|
Prior to Pike 7.5 the value 1 was returned for exited processes.
int(0..) last_signal()
Returns the last signal that was sent to the process.
int pid()
Returns the process identifier of the process.
int set_priority(string priority)
Sets the priority of the process. priority is one of the strings
constant Process.create_process.limit_value
Each limit_value may be either of:
sets current limit, max is left as it is.
([ "hard":int, "soft":int ]) Both values are optional, hard <= soft.
({ hard, soft }), both can be set to the string "unlimited". A value of -1 means 'keep the old value'.
The string "unlimited" sets both the hard and soft limit to unlimited
void Process.create_process(array(string) command_args, void|mapping modifiers)
The command name and its command-line arguments. You do not have to worry about quoting them; pike does this for you.
This optional mapping can can contain zero or more of the following parameters:
|
Process.create_process(({ "/usr/bin/env" }), (["env" : getenv() + (["TERM":"vt100"]) ]));
//! Spawn a new process with the args @[args] and optionally a //! standard input if you provide such a @[Stdio.File] object. //! @returns //! Returns the new process and a pipe from which you can read //! its output. array(Process.Process|Stdio.File) spawn(Stdio.File|void stdin, string ... args) { Stdio.File stdout = Stdio.File(); mapping opts = ([ "stdout" : stdout->pipe() ]); if( stdin ) opts->stdin = stdin; return ({ Process.create_process( args, opts ), stdout }); }
All parameters that accept both string or int input can be noticeably slower using a string instead of an integer; if maximum performance is an issue, please use integers.
The modifiers "callback", "fds",
"uid", "gid",
"nice", "noinitgroups", "setgroups",
"keep_signals" and "rlimit" only exist on unix.
Support for "callback" was added in Pike 7.7.
int kill(int signal)
|
This function is only available on platforms that support signals.
| CLASS Process.TraceProcess |
Class that enables tracing of processes.
The new process will be started in stopped state. Use cont() to let it start executing.
This class currently only exists on systems that implement ptrace().
inherit create_process : create_process
int wait()
Waits for the process to stop.
|
create_process::wait()
void cont(int|void signal)
Allow a traced process to continue.
Deliver this signal to the process.
This function may only be called for stopped processes.
wait()
void exit()
Cause the traced process to exit.
This function may only be called for stopped processes.
cont() , wait()
| CLASS Process.TraceProcess.Registers |
Interface to the current register contents of a stopped process.
TraceProcess
int `[](int regno)
Get the contents of register regno .
| Module Gnome |
| CLASS Gnome.Dialog |
Gnome.Dialog gives dialogs a consistent look and feel, while making them more convenient to program. Gnome.Dialog makes it easy to use stock buttons, makes it easier to handle delete_event, and adds some cosmetic touches (such as a separator above the buttons, and a bevel around the edge of the window).
Signals: clicked
close
inherit GTK.Window : Window
Gnome.Dialog append_button_with_pixmap(string name, string pixmap_file)
Gnome.Dialog button_connect(int button, function callback_cb, mixed callback_arg)
Simply a signal_connect to the "clicked" signal of the specified button.
Gnome.Dialog close()
See also close_hides(). This function emits the "close" signal( which either hides or destroys the dialog (destroy by default). If you connect to the "close" signal, and your callback returns TRUE, the hide or destroy will be blocked. You can do this to avoid closing the dialog if the user gives invalid input, for example.
Using close() in place of hide() or destroy() allows you to easily catch all sources of dialog closure, including delete_event and button clicks, and handle them in a central location.
Gnome.Dialog Gnome.Dialog(string title, string ... buttons)
Creates a new Gnome.Dialog, with the given title, and any button names in the arg list. Buttons can be simple names, such as "My Button", or gnome-stock defines such as GNOME.StockButtonOK, etc. The last argument should be NULL to terminate the list.
Buttons passed to this function are numbered from left to right, starting with 0. So the first button in the arglist is button 0, then button 1, etc. These numbers are used throughout the Gnome.Dialog API.
Gnome.Dialog editable_enters(GTK.Editable widget)
Normally if there's an editable widget (such as GtkEntry) in your dialog, pressing Enter will activate the editable rather than the default dialog button. However, in most cases, the user expects to type something in and then press enter to close the dialog. This function enables that behavior.
GTK.Vbox get_vbox()
int run()
Blocks until the user clicks a button or closes the dialog with the window manager's close decoration (or by pressing Escape).
You need to set up the dialog to do the right thing when a button is clicked or delete_event is received; you must consider both of those possibilities so that you know the status of the dialog when run() returns. A common mistake is to forget about Escape and the window manager close decoration; by default, these call close(), which by default destroys the dialog. If your button clicks do not destroy the dialog, you don't know whether the dialog is destroyed when run() returns. This is bad.
So you should either close the dialog on button clicks as well, or change the close() behavior to hide instead of destroy. You can do this with close_hides().
int run_and_close()
See run(). The only difference is that this function calls close() before returning if the dialog was not already closed.
Gnome.Dialog set_accelerator(int button, int accelerator_key, int accelerator_mode)
Gnome.Dialog set_close(int click_closes)
This is a convenience function so you don't have to connect callbacks to each button just to close the dialog. By default, Gnome.Dialog has this parameter set the FALSE and it will not close on any click. (This was a design error.) However, almost all the Gnome.Dialog subclasses, such as Gnome.MessageBox and Gnome.PropertyBox, have this parameter set to TRUE by default.
Gnome.Dialog set_default(int button)
The default button will be activated if the user just presses return. Usually you should make the least-destructive button the default. Otherwise, the most commonly-used button.
Gnome.Dialog set_parent(GTK.Window parent)
Dialogs have "parents," usually the main application window which spawned them. This function will let the window manager know about the parent-child relationship. Usually this means the dialog must stay on top of the parent, and will be minimized when the parent is. Gnome also allows users to request dialog placement above the parent window (vs. at the mouse position, or at a default window manger location).
Gnome.Dialog set_sensitive(int button, int sensitive)
Calls set_sensitive() on the specified button number.
| CLASS Gnome.StatusDocklet |
Some apps want to embed a very small icon or widget in the panel to display the status of the app. This can be done without the operational overhead of an applet. The status docklet will embed a 22 by 22 window inside the panel. This is not a separate applet and thus is minimally intrusive to the user and is meant for very temporary status displays for which a full applet would not be appropriate.
The way StatusDocklet works is a little different from how the AppletWidget works. Firstly, StatusDocklet object is not a widget, it is just an abstract GTK+ object. You create a new StatusDocklet object and then bind the "build_plug" signal which is emitted when the panel was contacted and a widget must be built. After binding the "build_plug" signal, you call run() to actually start trying to contacting the panel. StatusDocklet is safe to use without a panel. By default it will try to locate a panel for 15 minutes and after that it will give up. It will also handle panel restarts by default. If it does, your widget will be destroyed and "build_plug" will be emitted again when the new panel starts. Even though the panel will never restart by itself, the user might not run session management and thus might restart panel by hand, or due to a bug, the panel might crash and restart itself.
Docklets are not available in GNOME 1.0.
Signals: build_plug This signal is emitted when you actually need to build the widget that you want to place inside the plug in the status docklet. It should be 22 by 22, and if it is larger it will be cropped.
inherit GTK.Object : Object
Gnome.StatusDocklet Gnome.StatusDocklet()
Creates a new status docklet object with the default parameters. By default the docklet object will try to contact a panel 20 times. It will try to find a panel every 15 seconds. You need to bind the build_plug signal in which you build your own widget and add it to the provided container. By default the docklet object will handle a panel restart, in which case your widget will be destroyed and when the panel is contacted again the build_plug signal will be emitted again. You also must call the status_docklet_run function after you bind the build_plug signal.
GTK.Plug get_plug()
the current W(plug) holding the docklet
Gnome.StatusDocklet run()
Search for the panel and add the plug if it finds it. This function is also called internally from the timeout. If called externally more times, a panel lookup will be forced and one try will be wasted. You need to call this function at least once after binding the build_plug signal to tell the status docklet to start looking for the panel. If the status docklet handles restarts you don't have to call this function ever again.
| CLASS Gnome.DruidPageFinish |
This is a W(GnomeDruidPage).
inherit Gnome.DruidPage : DruidPage
Gnome.DruidPageFinish Gnome.DruidPageFinish()
Creates a new Gnome.DruidPageStandard widget.
Gnome.DruidPageFinish set_bg_color(GDK.Color color)
This will set the background color to be the specified color.
Gnome.DruidPageFinish set_logo_bg_color(GDK.Color color)
This will set the background color of the logo
Gnome.DruidPageFinish set_text(string text)
Set the text
Gnome.DruidPageFinish set_text_color(GDK.Color color)
Set the text color
Gnome.DruidPageFinish set_textbox_color(GDK.Color color)
This will set the textbox color to be the specified color.
Gnome.DruidPageFinish set_title(string title)
Set the title
Gnome.DruidPageFinish set_title_color(GDK.Color color)
Set the title color
| CLASS Gnome.ColorPicker |
This widget provides color selection facilities to your application. The widget appears as a button which contains a "color swatch" of the currently selected color. When the button is pressed, the widget presents the user with a color selection dialog where the color can be selected.
You can select the color to be displayed in a number of ways:
floating point values for the red, green and blue channels,
integers in the range 0 to 65,535, or integers in the range 0 to
255, depending on your needs.
Gnome.ColorPicker();
![]()
Signals: color_set This signal is emitted when the user changes the color on the color selector. The values passed to this signal are the red, green, blue and alpha channels selected in integer form in the range 0 to 65535.
inherit GTK.Button : Button
Gnome.ColorPicker Gnome.ColorPicker()
Creates a new GNOME color picker widget. This returns a widget in the form of a small button containing a swatch representing the current selected color. When the button is clicked, a color-selection dialog will open, allowing the user to select a color. The swatch will be updated to reflect the new color when the user finishes.
mapping get()
Returns a mapping ([ "d":([ "r":rvalue, "g":gvalue, "b":bvalue, "a":avalue ]), "i8":([ ... ]), "i16":([ .. ]) ]);
Gnome.ColorPicker set_d(float r, float g, float b, float a)
Set color shown in the color picker widget using floating point values. The values range between 0.0 and 1.0.
Gnome.ColorPicker set_dither(int dither)
Sets whether the picker should dither the color sample or just paint a solid rectangle.
Gnome.ColorPicker set_i16(int r, int g, int b, int a)
Set color shown in the color picker widget using integer values. The values range between 0 and 65535.
Gnome.ColorPicker set_i8(int r, int g, int b, int a)
Set color shown in the color picker widget using integer values. The values range between 0 and 255.
Gnome.ColorPicker set_title(string title)
Sets the title for the color selection dialog
Gnome.ColorPicker set_use_alpha(int use_alpha)
Sets whether or not the picker should use the alpha channel.
| CLASS Gnome.Calculator |
This widget provides a simple calculator that you can embed in your applications for doing quick computations.
The widget consists of a fully functional calculator including
standard arithmetic functions as well as trigonometric
capabilities, exponents, factorials, nested equations, and others.
Gnome.Calculator()

Signals: result_changed This signal is emited by the widget when the result has been changed.
inherit GTK.Vbox : Vbox
Gnome.Calculator clear(int reset)
Resets the calculator back to zero. If reset is TRUE, results stored in memory and the calculator mode are cleared also.
Gnome.Calculator Gnome.Calculator()
Create a new calculator widget
float get_result()
Value currently stored in calculator buffer.
Gnome.Calculator set(float result)
Sets the value stored in the calculator's result buffer to the given result.
| CLASS Gnome.AppletWidget |
Applets are basically GNOME applications whose window sits inside the panel. Also the panel "takes care" of the applets by providing them with session saving and restarting, window management (inside of the panel), and a context menu.
The simplest applet one can write would be along the lines of:
int main( int argc, array argv )
{
Gnome.init( "hello", "1.0", argv, 0 );
Gnome.AppletWidget("hello")->add(GTK.Label("Hello World!"))->show_all();
GTK.applet_widget_gtk_main();
}
This creates an applet which just sits on the panel, not really
doing anything, in real life the label would be substituted by
something which actually does something useful. As you can see the
applet doesn't really take care of restarting itself.
For the applet to be added to the menus, you need to install two files. Your x.gnorba file goes into $sysconfdir/CORBA/servers/ and the x.desktop file goes into $prefix/share/applets/<category>/.
Example hello.desktop:
[Desktop Entry]
Name=Hello Applet
Comment=An example Hello World type Applet
Type=PanelApplet
Exec=hello.pike
Icon=gnome-hello.png
Terminal=0
Example hello.gnorba:
[hello]
type=exe
repo_id=IDL:GNOME/Applet:1.0
description=Hello Applet
location_info=hello.pike
One thing to keep in mind is that the Exec line for the .desktop
doesn't actually get executed when the Type is PanelApplet. The
Exec line should be the GOAD ID specified in the .gnorba file (the
"hello" enclosed by brackets). For a simple applet all you need to
do is replace the hello.pike with the name of your applet
executable.
When the user right clicks on the applet, a menu appears, this is all handeled by the panel, so in order to add items to it you use a special interface to "add callbacks" to the menu. A very simple example would be (making our hello applet even more feature full):
void hello_there()
{
write( "Hello there, indeed!\n" );
}
int main( int argc, array argv )
{
Gnome.AppletWidget w;
Gnome.init( "hello", "1.0", argv, 0 );
w = Gnome.AppletWidget("hello");
w->add(GTK.Label("Hello World!"))->show_all();
w->register_callback( "hello", "Hello there", hello_there, 0 );
GTK.applet_widget_gtk_main();
}
Now the user will see a "Hello There" menu item on the applet menu,
and when selected, the applet will print "Hello There". Useful huh?
Note that the first argument to the register_callback is just a string identifier of this callback, and can really be whatever you want. But it should NOT be translated as the label (the 2nd argument) should be.
Signals: back_change
change_orient
change_pixel_size
change_position
tooltip_state
inherit GTK.Plug : Plug
Gnome.AppletWidget abort_load()
Abort the applet loading, once applet has been created, this is a way to tell the panel to forget about us if we decide we want to quit before we add the actual applet to the applet-widget. This is only useful before before add() is called.
Gnome.AppletWidget add(GTK.Widget what)
Add a child (widget) to the applet. This finishes the handshaking with the panel started in applet_widget_new. You should never call this function twice for the same applet. If you have already created an applet widget, but need to cancel the loading of the applet, use abort_load.
Gnome.AppletWidget callback_set_sensitive(string name, int sensitive)
Sets the sensitivity of a menu item in the applet's context menu.
Gnome.AppletWidget Gnome.AppletWidget(string applet_name)
Make a new applet and register us with the panel, if you decide to cancel the load before calling add, you should call abort_load.
int get_free_space()
Gets the free space left that you can use for your applet. This is the number of pixels around your applet to both sides. If you strech by this amount you will not disturb any other applets. If you are on a packed panel 0 will be returned.
string get_globcfgpath()
int get_panel_orient()
Gets the orientation of the panel this widget is on. it can be one of GNOME_Panel_ORIENT_DOWN , GNOME_Panel_ORIENT_LEFT , GNOME_Panel_ORIENT_RIGHT and GNOME_Panel_ORIENT_UP . This is not the position of the panel, but rather the direction that the applet should be "reaching out". So any arrows should for example point in this direction. It will be OrientUp or OrientDown for horizontal panels and OrientLeft or OrientRight for vertical panels
int get_panel_pixel_size()
Gets the width of the panel in pixels. This is not the actual size, but the recomended one. The panel may be streched if the applets use larger sizes then this.
string get_privcfgpath()
Gnome.AppletWidget register_callback(string name, string menutext, function callback_cb, mixed callback_arg)
Adds a menu item to the applet's context menu. The name should be a path that is separated by '/' and ends in the name of this item. You need to add any submenus with register_callback_dir.
Gnome.AppletWidget register_callback_dir(string name, string menutext)
Adds a submenu to the applet's context menu. The name should be the full path of the new submenu with the name of the new submenu as the last part of the path. The name can, but doesn't have to be terminated with a '/'.
Gnome.AppletWidget register_stock_callback(string name, string stock_type, string menutext, function callback_cb, mixed callback_arg)
Adds a menu item to the applet's context menu with a stock GNOME pixmap. This works almost exactly the same as register_callback.
Gnome.AppletWidget register_stock_callback_dir(string name, string stock_type, string menutext)
Adds a submenu to the applet's context menu with a stock GNOME pixmap. This is similiar to register_callback_dir.
Gnome.AppletWidget remove()
Remove the plug from the panel, this will destroy the applet. You can only call this once for each applet.
Gnome.AppletWidget send_position(int enable)
If you need to get a signal everytime this applet changes position relative to the screen, you need to run this function with TRUE for enable and bind the change_position signal on the applet. This signal can be quite CPU/bandwidth consuming so only applets which need it should use it. By default change_position is not sent.
Gnome.AppletWidget set_tooltip(string to)
Set a tooltip on the entire applet that will follow the tooltip setting from the panel configuration.
Gnome.AppletWidget set_widget_tooltip(GTK.Widget widget, string text)
Set a tooltip on the widget that will follow the tooltip setting from the panel configuration.
Gnome.AppletWidget sync_config()
Tell the panel to save our session here (just saves, no shutdown). This should be done when you change some of your config and want the panel to save it's config, you should NOT call this in the session_save handler as it will result in a locked panel, as it will actually trigger another session_save signal for you. However it also asks for a complete panel save, so you should not do this too often, and only when the user has changed some preferences and you want to sync them to disk. Theoretically you don't even need to do that if you don't mind loosing settings on a panel crash or when the user kills the session without logging out properly, since the panel will always save your session when it exists.
Gnome.AppletWidget unregister_callback(string name)
Remove a menu item from the applet's context menu. The name should be the full path to the menu item. This will not remove any submenus.
Gnome.AppletWidget unregister_callback_dir(string name)
Removes a submenu from the applet's context menu. Use this instead of unregister_callback to remove submenus. The name can be, but doesn't have to be terminated with a '/'. If you have not removed the subitems of this menu, it will still be shown but without it's title or icon. So make sure to first remove any items and submenus before calling this function.
| CLASS Gnome.NumberEntry |
Provides an entry line for numbers. This routine does not attempt
to do any validation on the valid number ranges, but provides a
button that will let the user bring up a calculator to fill in the
value of the entry widget.
Gnome.NumberEntry("", "Select a number...");
![]()
inherit GTK.Hbox : Hbox
Gnome.NumberEntry Gnome.NumberEntry(string history_id, string calc_dialog_title)
Creates a new number entry widget, with a history id and title for the calculator dialog.
float get_number()
Get the current number from the entry
Gnome.Entry gnome_entry()
Get the W(GnomeEntry) component of the Gnome.NumberEntry for lower-level manipulation.
GTK.Entry gtk_entry()
Get the W(Entry) component of the Gnome.NumberEntry for Gtk+-level manipulation.
Gnome.NumberEntry set_title(string title)
Set the title of the calculator dialog to calc_dialog_title. Takes effect the next time the calculator button is pressed.
| CLASS Gnome.IconSelection |
inherit GTK.Vbox : Vbox
Gnome.IconSelection add_defaults()
Adds the default pixmap directory into the selection widget.
Gnome.IconSelection add_directory(string dir)
Adds the icons from the directory dir to the selection widget.
Gnome.IconSelection clear(int|void not_shown)
Clear the currently shown icons, the ones that weren't shown yet are not cleared unless the not_shown parameter is given, in which case even those are cleared.
Gnome.IconSelection Gnome.IconSelection()
reates a new icon selection widget, it uses a W(GnomeIconList) for the listing of icons
string get_icon(int full_path)
Gets the currently selected icon name, if full_path is true, it returns the full path to the icon, if none is selected it returns 0.
Gnome.IconSelection select_icon(string filename)
Selects the icon filename. This icon must have already been added and shown
Gnome.IconSelection show_icons()
Shows the icons inside the widget that were added with add_defaults and add_directory. Before this function isf called the icons aren't actually added to the listing and can't be picked by the user.
| CLASS Gnome.Href |
This widget is a GtkButton button that contains a URL. When clicked it invokes the configured browser for the URL you provided.
Gnome.Href( "http://www.gnome.org", "GNOME Web Site" )
![]()
Gnome.Href( "http://www.gnome.org" )
![]()
inherit GTK.Button : Button
Gnome.Href Gnome.Href(string url, string|void label)
Created a GNOME href object, a label widget with a clickable action and an associated URL. If label is set to 0, url is used as the label.
string get_label()
Returns the contents of the label widget used to display the link text.
string get_url()
Return the url
Gnome.Href set_label(string label)
Sets the internal label widget text (used to display a URL's link text) to the given value.
Gnome.Href set_url(string url)
Sets the internal URL
| CLASS Gnome.App |
Toplevel GNOME applications would normally use one Gnome.App widget as their toplevel window. You can create as many Gnome.App widgets as you want, for example, some people use one GnomeApp per document their application loads.
Once you have created one instance of this widget, you would add your main application view information to this window by using set_contents() routine.
The GnomeApp has support for including a menubar, one or more toolbars and a statusbar for your application. It also takes care of intalling the accelerators for you when used in conjuction with the gnome-app-helper routines. The toolbars are inserted into Gnome.Dock widgets.
The gnome-app-helper module provides various helper routines to simplify the configuration of your menus and toolbars, but you can create those yourself and use the set_menus(), add_toolbar(), set_toolbar(), add_dock_item() and add_docked().
inherit GTK.Window : Window
Gnome.App add_dock_item(Gnome.DockItem item, int placement, int band_num, int band_position, int|void offset)
Create a new Gnome.DockItem widget containing widget, and add it to app's dock with the specified layout information. Notice that, if automatic layout configuration is enabled, the layout is overridden by the saved configuration, if any.
item : Item to be added to app's dock placement : Placement for the new dock item, one of Gnome.DockTop, Gnome.DockRight, Gnome.DockBottom, Gnome.DockLeft and Gnome.DockFloating band_num : Number of the band where the dock item should be placed band_position : Position of the new dock item in band band_num offset : Offset from the previous dock item in the band; if there is no previous item, offset from the beginning of the band.
Gnome.App add_docked(GTK.Widget widget, string name, int behavior, int placement, int band_num, int band_position, int|void offset)
Create a new Gnome.DockItem widget containing widget, and add it to app's dock with the specified layout information. Notice that, if automatic layout configuration is enabled, the layout is overridden by the saved configuration, if any.
widget : Widget to be added to app's dock name : Name for the dock item that will contain toolbar behavior : Behavior for the new dock item. One of GNOME_DOCK_ITEM_BEH_EXCLUSIVE , GNOME_DOCK_ITEM_BEH_LOCKED , GNOME_DOCK_ITEM_BEH_NEVER_FLOATING , GNOME_DOCK_ITEM_BEH_NEVER_HORIZONTAL , GNOME_DOCK_ITEM_BEH_NEVER_VERTICAL and GNOME_DOCK_ITEM_BEH_NORMAL placement : Placement for the new dock item, one of Gnome.DockTop, Gnome.DockRight, Gnome.DockBottom, Gnome.DockLeft and Gnome.DockFloating band_num : Number of the band where the dock item should be placed band_position : Position of the new dock item in band band_num offset : Offset from the previous dock item in the band; if there is no previous item, offset from the beginning of the band.
Gnome.App add_toolbar(GTK.Toolbar toolbar, string name, int behavior, int placement, int band_num, int band_position, int|void offset)
Create a new Gnome.DockItem widget containing toolbar, and add it to app's dock with the specified layout information. Notice that, if automatic layout configuration is enabled, the layout is overridden by the saved configuration, if any.
toolbar : Toolbar to be added to app's dock name : Name for the dock item that will contain toolbar behavior : Behavior for the new dock item. One or more of GNOME_DOCK_ITEM_BEH_EXCLUSIVE , GNOME_DOCK_ITEM_BEH_LOCKED , GNOME_DOCK_ITEM_BEH_NEVER_FLOATING , GNOME_DOCK_ITEM_BEH_NEVER_HORIZONTAL , GNOME_DOCK_ITEM_BEH_NEVER_VERTICAL and GNOME_DOCK_ITEM_BEH_NORMAL placement : Placement for the new dock item, one of Gnome.DockTop, Gnome.DockRight, Gnome.DockBottom, Gnome.DockLeft and Gnome.DockFloating band_num : Number of the band where the dock item should be placed band_position : Position of the new dock item in band band_num offset : Offset from the previous dock item in the band; if there is no previous item, offset from the beginning of the band.
Gnome.App Gnome.App(string appname, string|void title)
Create a new (empty) application window. You must specify the application's name (used internally as an identifier). title can be left as 0, in which case the window's title will not be set.
Gnome.App enable_layout_config(int enable)
Specify whether the the dock's layout configuration should be automatically saved via gnome-config whenever it changes, or not.
Gnome.Dialog error(string error)
An important fatal error; if it appears in the statusbar, it might gdk_beep() and require acknowledgement.
Gnome.App flash(string flash)
Flash the message in the statusbar for a few moments; if no statusbar, do nothing. For trivial little status messages, e.g. "Auto saving..."
Gnome.Dock get_dock()
retrieved the Gnome.Dock widget contained in the App
Gnome.DockItem get_dock_item_by_name(string name)
Gnome.Dialog message(string message)
A simple message, in an OK dialog or the status bar. Requires confirmation from the user before it goes away. Returns 0 or a dialog widget. If 0, the message is displayed in the status bar.
Gnome.App ok_cancel(string question, function callback, mixed cb_arg2)
Ask a ok or cancel question and call the callback when it's answered.
Gnome.App ok_cancel_modal(string question, function callback, mixed cb_arg2)
Ask a ok or cancel question, block the application while it is asked, and call the callback when it's answered.
Gnome.AppProgressKey progress_manual(string prompt)
Gnome.AppProgressKey progress_timeout(string prompt, int interval, function cb, mixed cb_arg1)
Gnome.App question(string question, function reply_callback, mixed cb_arg2)
Ask a yes or no question, and call the callback when it's answered.
Gnome.App question_modal(string question, function callback, mixed cb_arg2)
Ask a yes or no question, block the application while it is asked, and call the callback when it's answered.
Gnome.App request_password(string question, function callback, mixed cb_arg2)
As request string, but do not show the string
Gnome.App request_string(string question, function callback, mixed cb_arg2)
Request a string, and call the callback when it's answered.
Gnome.App set_contents(GTK.Widget contents)
Sets the status bar of the application window.
Gnome.App set_menus(GTK.MenuBar menu_bar)
Sets the menu bar of the application window.
Gnome.App set_statusbar(GTK.Widget statusbar)
Sets the status bar of the application window.
Gnome.App set_toolbar(GTK.Toolbar toolbar)
Sets the main toolbar of the application window.
Gnome.Dialog warning(string warning)
A not-so-important error, but still marked better than a flash
| CLASS Gnome.FileEntry |
This widget provides an entry box with history (a W(GnomeEntry))
and a button which can pop up a file selector dialog box
W(GtkFileSelection). It also accepts DND drops from the filemanager
and other sources.
Gnome.FileEntry("","")
![]()
Signals: browse_clicked Signal emitted when the "browse" button is clicked. This is so that you can add stuff to the file selector or to override this method.
inherit GTK.Hbox : Hbox
Gnome.FileEntry Gnome.FileEntry(string history_id, string browse_dialog_title)
Creates a new Gnome.FileEntry widget.
string get_full_path(int file_must_exist)
Gets the full absolute path of the file from the entry. If file_must_exist is false, nothing is tested and the path is returned. If file_must_exist is true, then the path is only returned if the path actually exists. In case the entry is a directory entry (see set_directory), then if the path exists and is a directory then it's returned; if not, it is assumed it was a file so we try to strip it, and try again.
Gnome.Entry gnome_entry()
Get the W(GnomeEntry) component of the widget for lower-level manipulation.
GTK.Entry gtk_entry()
Get the W(Entry) component of the widget for lower-level manipulation.
Gnome.FileEntry set_default_path(string path)
Set the default path of browse dialog to path. The default path is only used if the entry is empty or if the current path of the entry is not an absolute path, in which case the default path is prepended to it before the dialog is started.
Gnome.FileEntry set_directory(int directory_entry)
Sets whether this is a directory only entry. If directory_entry is true, then get_full_path will check for the file being a directory, and the browse dialog will have the file list disabled.
Gnome.FileEntry set_modal(int is_modal)
Sets the modality of the browse dialog.
Gnome.FileEntry set_title(string browse_dialog_title)
Set the title of the browse dialog to browse_dialog_title. The new title will go into effect the next time the browse button is pressed.
| CLASS Gnome.PixmapEntry |
Entry for large images with a preview. Unlike GnomeIconEntry, it
does not scale the images to a specific size and shows them
1:1. This is perfect for selection of backgrounds and such. It also
allows DND to be performed on the preview box. It also provides all
the GnomeEntry functionality as well.
Gnome.PixmapEntry("","browse...",1);

inherit GTK.Vbox : Vbox
Gnome.PixmapEntry Gnome.PixmapEntry(string history_id, string browse_dialog_title, int do_preview)
Creates a new pixmap entry widget, if do_preview is false, the preview is hidden but the files are still loaded so that it's easy to show it. For a pixmap entry without preview, use the W(GnomeFileEntry) widget.
string get_filename()
Gets the filename of the image if the preview successfully loaded.
Gnome.Entry gnome_entry()
Get the W(GnomeEntry) component of the W(GnomePixmapEntry) widget for lower-level manipulation.
Gnome.FileEntry gnome_file_entry()
Get the W(GnomeFileEntry) component of the W(GnomePixmapEntry) widget for lower-level manipulation.
Gnome.PixmapEntry set_pixmap_subdir(string dir)
Sets the default path for the file entry. The new subdirectory should be specified relative to the default GNOME pixmap directory.
Gnome.PixmapEntry set_preview(int do_preview)
Sets whether or not previews of the currently selected pixmap should be shown in the file selector.
Gnome.PixmapEntry set_preview_size(int min_w, int min_h)
Sets the minimum size of the preview frame in pixels.
| CLASS Gnome.DruidPageStandard |
This is a W(GnomeDruidPage).
inherit Gnome.DruidPage : DruidPage
Gnome.DruidPageStandard Gnome.DruidPageStandard()
Creates a new Gnome.DruidPageStandard widget.
Gnome.DruidPageStandard set_bg_color(GDK.Color color)
This will set the background color to be the specified color.
Gnome.DruidPageStandard set_logo_bg_color(GDK.Color color)
This will set the background color of the logo
Gnome.DruidPageStandard set_title(string title)
Set the title
Gnome.DruidPageStandard set_title_color(GDK.Color color)
Set the title color
| CLASS Gnome.DockItem |
inherit GTK.Bin : Bin
Gnome.DockItem Gnome.DockItem(string name, int behavior)
Create a new GnomeDockItem named name, with the specified behavior. Gnome.DockItemBehExclusive specifies that the dock item is always the only one in its band. Gnome.DockItemBehNeverFloating specifies that users cannot detach the dock item from the dock. Gnome.DockItemBehNeverVertical specifies that the dock item must be kept horizontal, and users cannot move it to a vertical band. Gnome.DockItemBehNeverHorizontal specifies that the dock item must be kept horizontal, and users cannot move it to a vertical band. Gnome.DockItemBehLocked specifies that users cannot drag the item around.
int get_behavior()
GTK.Widget get_child()
Retrieve the child of the item.
string get_name()
Retrieve the name
int get_orientation()
int get_shadow_type()
One of SHADOW_ETCHED_IN , SHADOW_ETCHED_OUT , SHADOW_IN , SHADOW_NONE and SHADOW_OUT
Gnome.DockItem set_orientation(int orientation)
Gnome.DockItem set_shadow_type(int shadow_type)
One of SHADOW_ETCHED_IN , SHADOW_ETCHED_OUT , SHADOW_IN , SHADOW_NONE and SHADOW_OUT
| CLASS Gnome.About |
A standard way of providing a small about box for your application. You provide the name of your application, version, copyright, a list of authors and some comments about your application. It also allows the programmer to provide a logo to be displayed.
Gnome.About( "Example", "1.0", "(c) Roxen IS 2000\n(c) IDA, LiU 2002", ({"Per Hedbor"}), "Some nice documentation\nabout this example" );

inherit Gnome.Dialog : Dialog
Gnome.About Gnome.About(string title, string version, string copyright, array authors, string comment, string|void logo)
Creates a new GNOME About dialog. title, version, copyright, and authors are displayed first, in that order. comments is typically the location for multiple lines of text, if necessary. (Separate with "\n".) logo is the filename of a optional pixmap to be displayed in the dialog, typically a product or company logo of some sort; omit this argument if no logo file is available.
| CLASS Gnome.IconEntry |
This widget provides the facilities to select an icon. An icon is displayed inside a button, when the button is pressed, an Icon selector (a dialog with a W(GnomeIconSelection) widget) pops up to let the user choose an icon. It also allows one to Drag and Drop the images to and from the preview button.
inherit GTK.Vbox : Vbox
Gnome.IconEntry Gnome.IconEntry(string history_id, string title)
Creates a new icon entry widget
string get_filename()
Gets the file name of the image if it was possible to load it into the preview. That is, it will only return a filename if the image exists and it was possible to load it as an image.
Gnome.Entry gnome_entry()
Get the W(GnomeEntry) widget that's part of the entry
Gnome.FileEntry gnome_file_entry()
Get the W(GnomeFileEntry) widget that's part of the entry
GTK.Entry gtk_entry()
Get the W(Entry) widget that's part of the entry
Gnome.IconEntry set_pixmap_subdir(string subdir)
Sets the subdirectory below gnome's default pixmap directory to use as the default path for the file entry.
| CLASS Gnome.Dock |
GnomeDock is a container widget designed to let users move around widgets such as toolbars, menubars and so on.
Every GnomeDock contains a widget called the "client area". On the four sides of the client area, there are four "dock areas", which can contain an arbitrary number of dockable widgets. All the dockable widgets should be GnomeDockItem widgets; the GnomeDockItem widget can in turn contain any kind of widget, and implements the dragging functionality: every GnomeDockItem has a handle that users can use to move them within the dock, or even move them outside it, so that they become "floating items".
Every "dock area" is implemented by means of zero or more "dock bands": a dock band is a horizontal or vertical stripe containing one or more dock items, and is implemented by the GnomeDockBand widget. Items are ordered from top to bottom in vertical bands, and from left to right in horizontal bands. Every dock item in a band is given an offset value that defines the distance, in pixels, from the previous item in the same band; if the item is first in the band, the offset defines the distance from the start of the band.
As a consequence, the position of an item in the dock can be specified by means of the following values: a "placement" specifying what area is being used (top, bottom, left, right), a "band number" specifying the number of the band within the specified area, a "position" within the band and a "offset" from the previous item in the same band.
Signals: layout_changed
inherit GTK.Container : Container
Gnome.Dock add_floating_item(Gnome.DockItem item, int x, int y, int orientation)
Add item to dock and make it floating at the specified (x, y) coordinates (relative to the root window of the screen).
Gnome.Dock add_item(Gnome.DockItem item, int placement, int band_num, int position, int offset, int new_band)
Add item to dock. placement can be either Gnome.DOCK_TOP, Gnome.DOCK_RIGHT, Gnome.DOCK_BOTTOM or Gnome.DOCK_LEFT, and specifies what area of the dock should contain the item. If in_new_band is TRUE, a new dock band is created at the position specified by band_num; otherwise, the item is added to the band_num'th band.
Gnome.Dock allow_floating_items(int allow)
Gnome.Dock Gnome.Dock()
GTK.Widget get_client_area()
Gnome.DockItem get_item_by_name(string name)
Gnome.Dock set_client_area(GTK.Widget area)
Specify a widget for the dock's client area.
| CLASS Gnome.AppProgressKey |
Wrapper for the opaque GnomeAppProgressKey type
Gnome.AppProgressKey destroy()
Gnome.AppProgressKey done()
Gnome.AppProgressKey set(float percent)
| CLASS Gnome.DruidPage |
This widget is a virtual widget to define the interface to a druid page. It's descendants are placed in a W(Gnome.Druid) widget.
Signals: back
cancel
finish
next
prepare
inherit GTK.Bin : Bin
| CLASS Gnome.Appbar |
A bar that GNOME applications put on the bottom of the windows to
display status, progress, hints for menu items or a minibuffer for
getting some sort of response. It has a stack for status messages
Gnome.Appbar( 1, 1, Gnome.PreferencesUser )->set_progress( 0.4 );
![]()
Signals: clear_prompt Emitted when the prompt is cleared
user_response Emitted when the user hits enter after a prompt
inherit GTK.Hbox : Hbox
Gnome.Appbar clear_prompt()
Remove any prompt.
Gnome.Appbar clear_stack()
Remove all status messages from appbar, and display default status message (if present).
Gnome.Appbar Gnome.Appbar(int has_progress, int has_status, int interactivity)
Create a new GNOME application status bar. If has_progress is TRUE, a small progress bar widget will be created, and placed on the left side of the appbar. If has_status is TRUE, a status bar, possibly an editable one, is created.
interactivity determines whether the appbar is an interactive "minibuffer" or just a status bar. If it is set to Gnome.PREFERENCES_NEVER, it is never interactive. If it is set to Gnome.PREFERENCES_USER we respect user preferences from ui-properties. If it's Gnome.PREFERENCES_ALWAYS we are interactive whether the user likes it or not. Basically, if your app supports both interactive and not (for example, if you use the gnome-app-util interfaces), you should use Gnome.PREFERENCES_USER. Otherwise, use the setting you support. Please note that "interactive" mode is not functional now; GtkEntry is inadequate and so a custom widget will be written eventually.
GTK.Progress get_progress()
Returns GTK.Progress widget pointer, so that the progress bar may be manipulated further.
string get_response()
Get the response to the prompt, if any.
Gnome.Appbar pop()
Remove current status message, and display previous status message, if any. It is OK to call this with an empty stack.
Gnome.Appbar push(string what)
Push a new status message onto the status bar stack, and display it.
Gnome.Appbar refresh()
Reflect the current state of stack/default. Useful to force a set_status to disappear.
Gnome.Appbar set_default(string default_status)
What to show when showing nothing else; defaults to "".
Gnome.Appbar set_progress(float percentage)
Sets progress bar to the given percentage. Pure sugar - with a bad name, in light of the get_progress name which is not the opposite of set_progress. Maybe this function should die.
Gnome.Appbar set_prompt(string prompt, int modal)
Put a prompt in the appbar and wait for a response. When the user responds or cancels, a user_response signal is emitted.
Gnome.Appbar set_status(string status)
Sets the status label without changing widget state; next set or push will destroy this permanently.
| CLASS Gnome.Druid |
The GNOME druid is a system for assisting the user with installing a service. It is roughly equivalent in functionality to the "Wizards" available in Windows.
There are two major parts of the druid, the Gnome.Druid widget, and the set of W(Gnome.DruidPage) widgets. The Gnome.Druid widget is the main widget that interacts with the user. It has a Next, a Prev, and a Cancel button, and acts as a container for the pages. It is not a top-level window, so it needs to be put in a W(GTK.Window) in almost all cases. The W(Gnome.DruidPage) is a virtual widget, from which all of the actual content of the page inherits from. There are currently three of these available within gnome-libs.
GNOME druids are fairly simple to program with. You start by creating a GnomeDruid into which you put all of your pages. This widget will handle the presentation of the W(GnomeDruidPage) widgets.
You then create all appropriate W(GnomeDruidPage) widgets. There are three implementations of these, although there is no reason why more couldn't be written. They are the W(GnomeDruidPageStart), the W(GnomeDruidPageStandard), and the W(GnomeDruidPageFinish). The W(GnomeDruidPageStandard) acts as a W(Container), and is probably the most commonly used druid page. The other ones, as their names might suggest, are used at the endpoints of the druid. More information on the specific properties of these widgets can be found on their respective pages.
You will need to add the pages to the druid in order for them to appear. The druid itself keeps an internal list of all pages, and using the prepend_page(), append_page(), and insert_page() functions will place them into it.
Signals: cancel This signal is emitted when the "cancel" button has been pressed. Note that the current druid page has the option to trap the signal and use it, if need be, preventing this signal from being emitted.
inherit GTK.Container : Container
Gnome.Druid append_page(Gnome.DruidPage page)
This will append a GnomeDruidPage into the internal list of pages that the druid has.
Gnome.Druid Gnome.Druid()
Create a new druid
Gnome.Druid insert_page(Gnome.DruidPage back_page, Gnome.DruidPage page)
This will insert page after back_page into the list of internal pages that the druid has. If back_page is not present in the list or is 0, page will be prepended to the list.
Gnome.Druid prepend_page(Gnome.DruidPage page)
This will prepend a GnomeDruidPage into the internal list of pages that the druid has.
Gnome.Druid set_buttons_sensitive(int beck_sensitive, int next_sensitive, int cancel_sensitive)
Sets the sensitivity of the druid's control-buttons. If the variables are TRUE, then they will be clickable. This function is used primarily by the actual W(GnomeDruidPage) widgets.
Gnome.Druid set_page(Gnome.DruidPage page)
This will make page the currently showing page in the druid. page must already be in the druid.
Gnome.Druid set_show_finish(int show_finish)
Sets the text on the last button on the druid. If show_finish is TRUE, then the text becomes "Finish". If show_finish is FALSE, then the text becomes "Cancel".
| CLASS Gnome.IconList |
The GNOME icon list widget can hold a number of icons with captions. The icons on the list can be selected (various selection methods are supported). The programmer can enable caption-editing for the icons. This parameters is configured when you create the icon list widget. You can control the type of selection mode you desire by using the set_selection_mode() function.
Signals: select_icon
text_changed
unselect_icon
inherit GTK.Widget : Widget
Gnome.IconList append(string icon_filename, string text)
Appends an icon to the specified icon list. The icon's image is loaded from the specified file, and it is inserted at the pos index.
Gnome.IconList clear()
Clears the contents for the icon list by removing all the icons. If destroy handlers were specified for any of the icons, they will be called with the appropriate data.
Gnome.IconList Gnome.IconList(int icon_widt, int flags)
Creates a new icon list widget. The icon columns are allocated a width of icon_width pixels. Icon captions will be word-wrapped to this width as well.
If flags has the Gnome.IconListIsEditable flag set, then the user will be able to edit the text in the icon captions, and the "text_changed" signal will be emitted when an icon's text is changed.
int find_icon_from_data(object data)
Find a icon in the list that has the given user data. If no icon is found, -1 is returned.
Gnome.IconList freeze()
Freezes an icon list so that any changes made to it will not be reflected on the screen until it is thawed with thaw(). It is recommended to freeze the icon list before inserting or deleting many icons, for example, so that the layout process will only be executed once, when the icon list is finally thawed.
You can call this function multiple times, but it must be balanced with the same number of calls to thaw() before the changes will take effect.
int get_icon_at(int x, int y)
Returns the index of the icon that is under the specified coordinates, which are relative to the icon list's window. If there is no icon in that position, -1 is returned.
object get_icon_data(int icon)
Return the data associated with a icon, or 0.
array get_selected_icons()
Return an array with the currently selected icons
int icon_is_visible(int pos)
returns 1 if the icon whose index is pos is visible.
Gnome.IconList insert(int pos, string icon_filename, string text)
Inserts an icon in the specified icon list. The icon's image is loaded from the specified file, and it is inserted at the pos index.
Gnome.IconList moveto(int pos, float yalign)
Makes the icon whose index is pos be visible on the screen. The icon list gets scrolled so that the icon is visible. An alignment of 0.0 represents the top of the visible part of the icon list, and 1.0 represents the bottom. An icon can be centered on the icon list using 0.5 as the yalign.
Gnome.IconList remove(int pos)
Removes the icon at index position pos. If a destroy handler was specified for that icon, it will be called with the appropriate data.
Gnome.IconList select_icon(int idx)
Selects the specified icon.
Gnome.IconList set_col_spacing(int pixels)
Sets the spacing to be used between columns of icons.
Gnome.IconList set_hadjustment(GTK.Adjustment hadj)
Sets the adjustment to be used for horizontal scrolling. This is normally not required, as the icon list can be simply inserted in a W(ScrolledWindow) and scrolling will be handled automatically.
Gnome.IconList set_icon_border(int pixels)
Set the width of the border to be displayed around an icon's image. This is currently not implemented.
Gnome.IconList set_icon_data(int icon, object data)
Set the user data associated with the specified icon. This data can be used to find icons, and when an icon is selected it can be easily retrieved using get_icon_data.
You can only use objects as icon data right now
Gnome.IconList set_icon_width(int w)
Sets the amount of horizontal space allocated to the icons, i.e. the column width of the icon list
Gnome.IconList set_row_spacing(int pixels)
Sets the spacing to be used between rows of icons.
Gnome.IconList set_selection_mode(int mode)
One of SELECTION_BROWSE , SELECTION_EXTENDED , SELECTION_MULTIPLE and SELECTION_SINGLE .
Gnome.IconList set_separators(string sep)
Set the characters that can be used as word separators when doing word-wrapping of the text captions.
Gnome.IconList set_text_spacing(int pixels)
Sets the spacing to be used between the icon and its caption
Gnome.IconList set_vadjustment(GTK.Adjustment hadj)
Sets the adjustment to be used for vertical scrolling. This is normally not required, as the icon list can be simply inserted in a W(ScrolledWindow) and scrolling will be handled automatically.
Gnome.IconList thaw()
Unfreeze the icon list
Gnome.IconList unselect_all()
Unselect all icons.
Gnome.IconList unselect_icon(int idx)
Unselects the specified icon.
| CLASS Gnome.FontPicker |
GnomeFontPicker - Button that displays current font; click to select new font.
Gnome.FontPicker();
![]()
Gnome.FontPicker()->set_mode( Gnome.FontPickerModeFontInfo );
![]()
Signals: font_set
inherit GTK.Button : Button
Gnome.FontPicker Gnome.FontPicker()
Create a new font pick button
Gnome.FontPicker fi_set_show_size(int show_size)
If show_size is TRUE, font size will be displayed along with font chosen by user. This only applies if current button mode is Gnome.FontPickerModeFontInfo.
Gnome.FontPicker fi_set_use_font_in_label(int use_font_in_label, int size)
If use_font_in_label is TRUE, font name will be written using font chosen by user and using size passed to this function. This only applies if current button mode is Gnome.FontPickerModeFontInfo.
GDK.Font get_font()
Retrieves the font from the font selection dialog.
string get_font_name()
Retrieve name of font from font selection dialog.
int get_mode()
Returns current font picker button mode (or what to show).
string get_preview_text()
Retrieve preview text from font selection dialog if available.
int set_font_name(string fontname)
Set or update the currently displayed font in the font picker dialog
Gnome.FontPicker set_mode(int mode)
Set value of subsequent font picker button mode (or what to show). Mode is one of GNOME_FONT_PICKER_MODE_FONT_INFO , GNOME_FONT_PICKER_MODE_PIXMAP , GNOME_FONT_PICKER_MODE_UNKNOWN and GNOME_FONT_PICKER_MODE_USER_WIDGET
Gnome.FontPicker set_preview_text(string text)
Set preview text in font picker, and in font selection dialog if one is being displayed.
Gnome.FontPicker set_title(string title)
Sets the title for the font selection dialog.
Gnome.FontPicker uw_set_widget(GTK.Widget widget)
Set the user-supplied widget as the inside of the font picker. This only applies with Gnome.FontPickerModeUserWidget.
| CLASS Gnome.DruidPageStart |
This is a W(GnomeDruidPage). It is meant to be used to introduce the user to what is being installed in a consistent manner.
inherit Gnome.DruidPage : DruidPage
Gnome.DruidPageStart Gnome.DruidPageStart()
Creates a new Gnome.DruidPageStart widget.
Gnome.DruidPageStart set_bg_color(GDK.Color color)
This will set the background color to be the specified color.
Gnome.DruidPageStart set_logo_bg_color(GDK.Color color)
This will set the background color of the logo
Gnome.DruidPageStart set_text(string text)
Set the text
Gnome.DruidPageStart set_text_color(GDK.Color color)
Set the text color
Gnome.DruidPageStart set_textbox_color(GDK.Color color)
This will set the textbox color to be the specified color.
Gnome.DruidPageStart set_title(string title)
Set the title
Gnome.DruidPageStart set_title_color(GDK.Color color)
Set the title color
| CLASS Gnome.DockLayout |
The Gnome.DockLayout widget is meant to make it simple for programmers to handle the layout of a GnomeDock widget.
Gnome.DockLayout can contain an arbitrary number of W(Gnome.DockItem) widgets, each of them with its own placement information. It is possible to "extract" a layout from an existing W(GnomeDock) widget, as well as adding the items present in a Gnome.DockLayout to it. Moreover, Gnome.DockLayout is able to create a layout configuration string that can be later used to re-construct the layout on a brand new Gnome.DockLayout widget.
As a consequence, Gnome.DockLayout is very useful to save and retrieve W(GnomeDock) configurations into files. For example, W(GnomeApp) uses Gnome.DockLayout to create a default layout configuration, override it with the user-specific configuration file, and finally apply it to it's W(GnomeDock).
inherit GTK.Object : Object
int add_floating_item(Gnome.DockItem item, int x, int y, int orientation)
Add item to the layout as a floating item with the specified (x, y) position and orientation.
int add_item(Gnome.DockItem item, int placement, int band_num, int band_position, int offset)
Add item to the layout with the specified parameters.
int add_to_dock(Gnome.Dock dock)
Add all the items in this layout to the specified dock
Gnome.DockLayout Gnome.DockLayout()
Create a new Gnome.DockLayout widget.
string create_string()
Generate a string describing the layout
Gnome.DockLayoutItem get_item(Gnome.DockItem item)
Retrieve a dock layout item.
Gnome.DockLayoutItem get_item_by_name(string name)
Retrieve the dock layout item named name
Gnome.DockLayout parse_string(string str)
Parse the layout string str, and move around the items in layout accordingly.
int remove_item(Gnome.DockItem item)
Remove the specified item from the layout.
int remove_item_by_name(string name)
Remove the specified item from the layout.
| CLASS Gnome.Less |
This widget implements a graphical "more" command. It allows the user to view a text file. There are various possible ways to specify the contents to display: loading the data from a file (by providing a filename) or by loading it from an open file data stream or from the output of a Unix command.
Gnome.Less()->show_string("Example string\nshown in this\nwidget")

Gnome.Less()->show_file("/usr/dict/words" );

Gnome.Less()->show_command( "psrinfo -v" )

inherit GTK.Vbox : Vbox
Gnome.Less clear()
Clears all the text
Gnome.Less Gnome.Less()
Creates a new GnomeLess widget.
Gnome.Less reshow()
Re-displays all of the text in the GnomeLess widget gl. If the font has changed since the last show/reshow of text, it will update the current text to the new font.
Gnome.Less set_fixed_font(int fixed)
Specifies whether or not new text should be displayed using a fixed font. Pass TRUE in fixed to use a fixed font, or FALSE to revert to the default GtkText font.
Note: This will not affect text already being displayed. If you use this function after adding text to the widget, you must show it again by using gnome_less_reshow or one of the gnome_less_show commands.
Gnome.Less set_font(GDK.Font font)
Sets the font of the text to be displayed in the GnomeLess widget gl to font. Note: This will not affect text already being displayed. If you use this function after adding text to the widget, you must show it again by using reshow or one of the show commands.
Gnome.Less show_command(string command_line)
Runs the shell command specified in command_line, and places the output of that command in the GnomeLess widget specified by gl. Replaces any text already being displayed in the widget.
Gnome.Less show_file(string file)
Displays a file in a GnomeLess widget. Replaces any text already being displayed in the widget.
Gnome.Less show_filestream(Stdio.File stream)
Gnome.Less show_string(string data)
Displays a string in the GnomeLess widget gl. Replaces any text already being displayed.
int write_file(string path)
Writes the text displayed in the GnomeLess widget gl to the file specified by path.
int write_filestream(Stdio.File fd)
| CLASS Gnome.PaperSelector |
Gnome.PaperSelector()

inherit GTK.Vbox : Vbox
Gnome.PaperSelector Gnome.PaperSelector()
float get_bottom_margin()
float get_height()
float get_left_margin()
string get_name()
float get_right_margin()
float get_top_margin()
float get_width()
| CLASS Gnome.DateEdit |
The GnomeDateEdit widget provides a way to enter dates and times
with a helper calendar to let the user select the date.
Gnome.DateEdit(time(),1,1);
![]()
Gnome.DateEdit(time(),0,1);
![]()
Signals: date_changed
time_changed
inherit GTK.Hbox : Hbox
Gnome.DateEdit Gnome.DateEdit(int the_time, int show_time, int use_24_format)
Creates a new GnomeDateEdit widget which can be used to provide an easy to use way for entering dates and times.
int get_date()
Returns the configured time
Gnome.DateEdit set_popup_range(int low_hour, int high_hour)
Sets the range of times that will be provide by the time popup selectors.
Gnome.DateEdit set_time(int the_time)
Changes the displayed date and time in the GnomeDateEdit widget to be the one represented by the_time.
| CLASS Gnome.MessageBox |
The GnomeMessageBox widget creates dialog boxes (of type GnomeDialog) that contain a severity level (indicated by an icon and a title), a message to be displayed and a list of buttons that will be in the dialog.
The programmer will use strings desired for each button. If the strings are any of the GNOME_STOCK macros, then instead of creating a button with the text, the button will be a GNOME stock button with a stock icon.
The list of known types for message boxes are:
GNOME_MESSAGE_BOX_ERROR , GNOME_MESSAGE_BOX_GENERIC , GNOME_MESSAGE_BOX_INFO , GNOME_MESSAGE_BOX_QUESTION and GNOME_MESSAGE_BOX_WARNING .
Gnome.MessageBox( "This is a nice message", Gnome.MessageBoxInfo, Gnome.StockButtonOk, Gnome.StockButtonCancel );
![]()
Gnome.MessageBox( "This is another not so nice message", Gnome.MessageBoxError, Gnome.StockButtonClose, Gnome.StockButtonCancel );
![]()
inherit Gnome.Dialog : Dialog
Gnome.MessageBox Gnome.MessageBox(string message, string messagebox_type, string ... buttons)
Creates a dialog box of type message_box_type with message. A number of buttons are inserted on it. You can use the GNOME stock identifiers to create gnome stock buttons.
| CLASS Gnome.Scores |
This is a high-scores dialog box. The GNOME libraries also handle loading/saving systemwide high scores in a secure way.
Gnome.Scores( 17, ({ "per" })*17, map((array(float))indices(allocate(17)),`*,42), map(indices(allocate(17)), `*, 10 ), 1 )

inherit Gnome.Dialog : Dialog
Gnome.Scores Gnome.Scores(int n_scores, array names, array scores, array times, int clear)
Gnome.Scores set_color(int pos, GDK.Color color)
Gnome.Scores set_current_player(int index)
Gnome.Scores set_def_color(GDK.Color color)
Gnome.Scores set_logo_label_title(string txt)
Gnome.Scores set_logo_pixmap(string logofile)
Gnome.Scores set_logo_widget(GTK.Widget widget)
| CLASS Gnome.DockLayoutItem |
Information about an item in a gnome_dock_layout
Gnome.DockItem get_item()
The W(gnome_dock_item) this information applies to.
int get_placement()
One of
mapping position()
Get the position of the item
| CLASS Gnome.Entry |
This widget is a wrapper around the GtkEntry widget, but it provides a history mechanism for all the input entered into the widget. The way this works is that a special identifier is provided when creating the GnomeEntry widget, and this identifier is used to load and save the history of the text.
Gnome.Entry( "history" )
![]()
inherit GTK.Combo : Combo
Gnome.Entry append_history(int save, string text)
Adds a history item of the given text to the tail of the history list inside gentry. If save is TRUE, the history item will be saved in the config file (assuming that gentry's history id is not 0).
Gnome.Entry Gnome.Entry(string|void history_id)
Creates a new GnomeEntry widget. If history_id is not 0, then the history list will be saved and restored between uses under the given id.
GTK.Entry gtk_entry()
Obtain pointer to Gnome.Entry's internal GTK.Entry text entry
Gnome.Entry load_history()
Loads a stored history list from the GNOME config file, if one is available. If the history id of gentry is 0, nothing occurs.
Gnome.Entry prepend_history(int save, string text)
Adds a history item of the given text to the head of the history list inside gentry. If save is TRUE, the history item will be saved in the config file (assuming that gentry's history id is not 0).
Gnome.Entry save_history()
Force the history items of the widget to be stored in a configuration file. If the history id of gentry is 0, nothing occurs.
Gnome.Entry set_history_id(string|void history_id)
Set or clear the history id of the GnomeEntry widget. If history_id is 0, the widget's history id is cleared. Otherwise, the given id replaces the previous widget history id.
| CLASS Gnome.DockBand |
Gnome.DockBand is a widget implementing a "dock band", i.e. a horizontal or vertical stripe containing dockable widgets.
The application programmer does not normally need to use Gnome.DockBand directly; they are mostly used by the W(GnomeDock) widget to implement its functionality. For an explanation of the way dock bands are used within a dock, check out the documentation for the W(GnomeDock) widget.
inherit GTK.Container : Container
int append(Gnome.DockItem child, int offset)
Add child to the band with the specified offset as the last element.
Gnome.DockBand Gnome.DockBand()
Create a new Gnome.DockBand widget.
int get_child_offset(GTK.Widget child)
Retrieve the offset of the child
Gnome.DockItem get_item_by_name(string name)
Retrieve a named item from the band.
int get_num_children()
Retrieve the number of children
int get_orientation()
Retrieve the orientation
int insert(Gnome.DockItem child, int offset, int position)
Add child to the band at the specified position, with the specified offset from the previous item (or from the beginning of the band, if this is the first item).
Gnome.DockBand layout_add(Gnome.DockLayout layout, int placement, int band_num)
int prepend(Gnome.DockItem child, int offset)
Add child to the band with the specified offset as the first element.
Gnome.DockBand set_child_offset(GTK.Widget child, int offset)
Set the offset for the specified child of the band.
Gnome.DockBand set_orientation(int orientation)
Set the orientation.
| CLASS Gnome.PropertyBox |
The Gnome.PropertyBox widget simplifies coding a consistent dialog box for configuring properties of any kind.
The Gnome.PropertyBox is a toplevel widget (it will create its own window), inside it contains a GtkNotebook which is used to hold the various property pages.
The box will include ok, cancel, apply and help buttons (the actual buttons depends on the settings the user has, for example, apply can be hidden). The ok and apply buttons will start up in non-sensitive state, the programmer needs to configure the widgets inserted into the property box to inform the widget of any state changes to enable the ok and apply buttons. This is done by calling the changed() function.
To use this widget, you create the widget and then you call append_page() for each property page you want in the property box.
The widget emits two signals: "apply" and "help". To make a functional dialog box you will want to connect to at least the "apply" signal. Your function will be invoked once for each page and one more time at the end, passing a special value of -1 for the page number.
Signals: apply This signal is invoked with the page number that is being applied. The signal is emited with the special page number -1 when it has finished emiting the signals for all of the property pages.
help This signal is invoked when the user clicks on the help button in the property box. An argument is passed that identifies the currently active page number.
inherit Gnome.Dialog : Dialog
int append_page(GTK.Widget child, GTK.Widget tab_label)
Appends a new page to the Gnome.PropertyBox. widget is the widget that is being inserted, and tab_label will be used as the label for this configuration page.
Gnome.PropertyBox changed()
When a setting has changed, the code needs to invoke this routine to make the Ok/Apply buttons sensitive.
Gnome.PropertyBox Gnome.PropertyBox()
Creates a new Gnome.PropertyBox widget.
Gnome.PropertyBox set_state(int state)
| Module Arg |
| CLASS Arg.Options |
The option parser class that contains all the argument objects.
inherit LowOptions : LowOptions
| Module Getopt |
Getopt is a group of functions which can be used to find command line options.
Command line options come in two flavors: long and short. The short ones consists of a dash followed by a character (-t), the long ones consist of two dashes followed by a string of text (--test). The short options can also be combined, which means that you can write -tda instead of -t -d -a.
Options can also require arguments, in which case they cannot be combined. To write an option with an argument you write -t argument or -targument or --test=argument.
string|int(0..1) find_option(array(string) argv, array(string)|string shortform, array(string)|string|void longform, array(string)|string|void envvars, string|int(0..1)|void def, int|void throw_errors)
This is a generic function to parse command line options of the type -f, --foo or --foo=bar.
The first argument should be the array of strings that was sent as
the second argument to your main() function.
The second is a string with the short form of your option. The short form must be only one character long. It can also be an array of strings, in which case any of the options in the array will be accepted.
This is an alternative and maybe more readable way to give the
same option. If you give "foo" as longform your program
will accept --foo as argument. This argument can also be
an array of strings, in which case any of the options in the
array will be accepted.
This argument specifies an environment variable that can be used to specify the same option, to make it easier to customize program usage. It can also be an array of strings, in which case any of the mentioned variables in the array may be used.
This argument has two functions: It specifies if the option takes an argument or not, and it informs find_option() what to return if the option is not present. If def is given and the option does not have an argument find_option() will fail. def can be specified as UNDEFINED or left out if the option does not take an argument.
If throw_errors has been specified find_option() will
throw errors on failure. If it has been left out, or is
0 (zero), it will instead print an error message on
Stdio.stderr and exit the program with result code 1 on
failure.
Returns the value the option has been set to if any.
If the option is present, but has not been set to anything
1 will be returned.
Otherwise if any of the environment variables specified in envvars has been set, that value will be returned.
If all else fails, def will be returned.
If an option that requires an argument lacks an argument and throw_errors is set an error will be thrown.
find_option() modifies argv . Parsed options will be removed from argv . Elements of argv that have been removed entirely will be replaced with zeroes.
This function reads options even if they are written after the first non-option on the line.
Index 0 (zero) of argv is not scanned for options,
since it is reserved for the program name.
Only the first ocurrance of an option will be parsed. To parse multiple ocurrances, call find_option() multiple times.
Getopt.get_args()
constant Getopt.HAS_ARG
Used with find_all_options() to indicate that an option requires an argument.
find_all_options()
constant Getopt.NO_ARG
Used with find_all_options() to indicate that an option does not take an argument.
find_all_options()
constant Getopt.MAY_HAVE_ARG
Used with find_all_options() to indicate that an option takes an optional argument.
find_all_options()
array(array) find_all_options(array(string) argv, array(array(array(string)|string|int)) options, void|int(-1..1) posix_me_harder, void|int throw_errors)
This function does the job of several calls to find_option() . The main advantage of this is that it allows it to handle the POSIX_ME_HARDER environment variable better. When the either the argument posix_me_harder or the environment variable POSIX_ME_HARDER is true, no arguments will be parsed after the first non-option on the command line.
The should be the array of strings that was sent as the second
argument to your main() function.
Each element in the array options should be an array on the following form:
| ||||||||||||
Only the first three elements need to be included.
Don't scan for arguments after the first non-option.
If throw_errors has been specified find_all_options() will
throw errors on failure. If it has been left out, or is
0 (zero), it will instead print an error message on
Stdio.stderr and exit the program with result code 1 on
failure.
The good news is that the output from this function is a lot simpler. find_all_options() returns an array where each element is an array on this form:
| ||||||
find_all_options() modifies argv .
Index 0 (zero) of argv is not scanned for options,
since it is reserved for the program name.
Getopt.get_args() , Getopt.find_option()
array(string) get_args(array(string) argv, void|int(-1..1) posix_me_harder, void|int throw_errors)
This function returns the remaining command line arguments after you have run find_option() or find_all_options() to find all the options in the argument list. If there are any options left not handled by find_option() or find_all_options() this function will fail.
If throw_errors has been specified get_args() will throw errors on failure. If it has been left out, or is 0 (zero), it will instead print an error message on Stdio.stderr and exit the program with result code 1 on failure.
On success a new argv array without the parsed options is returned.
Getopt.find_option() , Getopt.find_all_options()
| Module Local |
Local gives a local module namespace used for locally installed pike modules. Modules are searched for in the directory pike_modules which can be located in the user's home directory or profile directory, or in any of the system directories /opt/share, /usr/local/share, /opt or /usr/local/. The user's home directory is determined by examining the environment variable HOME, and if that fails the environment variable USERPROFILE. If the environment variable PIKE_LOCAL_PATH is set, the paths specified there will be searched first.
Local.add_path() , Local.remove_path()
inherit __joinnode : __joinnode
int(0..1) add_path(string path)
This function prepends path to the Local module searchpath.
The path to the directory to be added.
Returns 1 on success, otherwise 0.
void remove_path(string path)
This function removes path from the Local module searchpath. If path is not in the search path, this is a noop.
The path to be removed.
| Module Array |
General functions to operate on arrays.
mixed reduce(function fun, array arr, mixed|void zero)
reduce() sends the first two elements in arr to fun , then the result and the next element in arr to fun and so on. Then it returns the result. The function will return zero if arr is the empty array. If arr has only one element, that element will be returned.
rreduce()
mixed rreduce(function fun, array arr, mixed|void zero)
rreduce() sends the last two elements in arr to fun , then the third last element in arr and the result to fun and so on. Then it returns the result. The function will return zero if arr is the empty array. If arr has only one element, that element will be returned.
reduce()
array shuffle(array arr)
shuffle() gives back the same elements, but in random order. The array is modified destructively.
permute()
array(array) combinations(array arr, int len)
Returns an array of all combinations of length len of elements from arr .
permute()
int search_array(array arr, string|function|int fun, mixed ... args)
search_array() works like map() , only it returns the index of the first call that returnes true instead.
If no call returns true, -1 is returned.
sum() , map()
array sum_arrays(function(int(0..0) ... :mixed) sum, array ... args)
Applies the function sum columnwise on the elements in the
provided arrays. E.g. sum_array(`+,a,b,c) does the same
as `+(a[*],b[*],c[*]).
array sort_array(array arr, function|void cmp, mixed ... args)
This function sorts the array arr after a compare-function
cmp which takes two arguments and should return 1 if the
first argument is larger then the second. Returns the sorted array
- arr is not sorted destructively.
The remaining arguments args will be sent as 3rd, 4th etc. argument to cmp .
If cmp is omitted, `>() is used instead.
map() , sort() , `>() , dwim_sort_func , lyskom_sort_func , oid_sort_func
array(array) columns(array x, array ind)
Get multiple columns from an array.
This function is equvivalent to
map(ind, lambda(mixed i) { return column(x, i); })
column()
array(array(array)) diff3(array a, array b, array c)
Return the three-way difference between the arrays.
Array.diff() , Array.diff_longest_sequence()
array(array(array)) compact_diff3(array a, array b, array old)
Given three arrays like those returned from diff3 , this function "compacts" the diff3 result by removing all differences where a and b agrees against old. The result is on the same form as the result from diff , and doesn't include the sequence from old.
int(-1..1) dwim_sort_func(string a, string b)
Sort without respect to number formatting (most notably leading zeroes).
int(-1..1) lyskom_sort_func(string a, string b)
Sort comparison function that does not care about case, nor about the contents of any parts of the string enclosed with '()'
Example: "Foo (bar)" is given the same weight as "foo (really!)"
array flatten(array a, mapping(array:array)|void state)
Flatten a multi-dimensional array to a one-dimensional array.
Prior to Pike 7.5.7 it was not safe to call this function with cyclic data-structures.
mixed sum(array a)
Sum the elements of an array using `+. The empty array results in 0.
array uniq2(array a)
Perform the same action as the Unix uniq command on an array, that is, fold consecutive occurrences of the same element into a single element of the result array:
aabbbcaababb -> abcabab.
See also the uniq function.
array arrayify(void|array|mixed x)
Make an array of the argument, if it isn't already. A zero_type argument gives the empty array. This is useful when something is either an array or a basic datatype, for instance in headers from the MIME module or Protocols.HTTP.Server.
Result depends of the argument type:
arrayify(x) => x
arrayify(x) => ({})
arrayify(x) => ({ x })
int(-1..1) oid_sort_func(string a, string b)
Sort with care of numerical sort for OID values, e.g. "1.2.1" before "1.11.1".
|
In Pike 7.6 and older this function returned 0 both when
a<b and a==b.
sort_array
array(array(array)) greedy_diff(array from, array to)
Like Array.diff , but tries to generate bigger continuous chunks of the
differences, instead of maximizing the number of difference chunks. More
specifically, greedy_diff optimizes the cases where Array.diff returns
({ ..., A, Z, B, ({}), C, ... })
({ ..., A, X, B, Y+B, C, ... })
into the somewhat shorter diff arrays
({ ..., A, Z, B+C, ... })
({ ..., A, X+B+Y, B+C, ... })
int count(array|mapping|multiset haystack, mixed needle)
mapping(mixed:int) count(array|mapping|multiset haystack)
Returns the number of occurrences of needle in haystack . If the optional needle argument is omitted, count instead works similar to the unix command sort|uniq -c, returning a mapping with the number of occurrences of each element in haystack . For array or mapping haystack s, it's the values that are counted, for multisets the indices, as you'd expect.
String.count , search , has_value
array common_prefix(array(array) arrs)
Find the longest common prefix from an array of arrays.
String.common_prefix
int(0..1) all(array a, function(int(0..0):mixed) predicate, mixed ... extra_args)
Returns 1 if all of the elements in a fulfills the requirement predicate ( a [i], @extra_args ), otherwise 0. The predicate should return non-zero for an element that meets the requirements and zero for those that do not.
Array.all( ({ 2, 4, 6, 8 }), `<, 17 )
any , has_value
int(0..1) any(array a, function(int(0..0):mixed) predicate, mixed ... extra_args)
Returns 1 if any of the elements in a fulfills the requirement predicate ( a [i], @extra_args ), otherwise 0. The predicate should return non-zero for an element that meets the requirements and zero for those that do not.
Array.any( ({ 2, 4, 6, 8 }), `>, 5 )
all , has_value
array(array) partition(array a, function(int(0..0):mixed) arbiter, mixed ... extra_args)
Splits an array in two, according to an arbitration function arbiter . The elements in a who return non-zero for the expression arbiter ( a [i], @extra_args ) end up in the first sub-array, the others in the second. The order is preserved from the original array.
Array.partition( enumerate( 9 ), lambda(int n) { return n>3 && n<7; } ); > ({ ({ 4, 5, 6 }), ({ 0, 1, 2, 3, 7, 8 }) })
filter , `/ , `%
array push(array list, mixed element)
Threats an Array as a stack and pushes the element onto the end.
Array.push(({ "a", "b", "c", "d" }), "e"); > ({ "a", "b", "c", "d", "e" })
ADT.Stack , ADT.Stack.push
array pop(array list)
Pops and returns the last value of the array, shortening the array by one element. If there are no elements in the array then 0 is returned otherwise an array is returned where the first returned element is the popped value, and the second element is the modified array.
Array.pop(({ "a", "b", "c", "d" })); > ({ "d", ({ "a", "b", "c" }) })
ADT.Stack , ADT.Stack.pop , ADT.Stack.quick_pop
array shift(array list)
Shifts the first value of the array off and returns it, shortening the array by 1 and moving everything down. If there are no elements in the array it returns 0. Returns an array where the first element is the shifted value and the second element is the modified array.
Array.shift(({ "a", "b", "c", "d"})); > ({ "a", ({ "b", "c", "d" }) })
ADT.Stack
array unshift(array list, mixed element)
Does the opposite of "shift". Or the opposite of a "push", depending on how you look at it. Prepends the element to the front of the array and returns the new array.
Array.unshift(({ "b", "c", "d" }), "a"); > ({ "a", "b", "c", "d" })
ADT.Stack
array(int) interleave_array(array(mapping(int:mixed)) tab)
Interleave a sparse matrix.
Returns an array with offsets that describe how to shift the rows of tab so that only at most one non-zero value exists in every column.
array(int) longest_ordered_sequence(array a)
Find the longest ordered sequence of elements.
This function returns an array of the indices in the longest ordered sequence of elements in the array.
diff()
array permute(array in, int number)
Give a specified permutation of an array.
The number of permutations is equal to sizeof(in )!
(the factorial of the size of the given array).
shuffle()
array(array(array)) diff(array a, array b)
Calculates which parts of the arrays that are common to both, and which parts that are not.
Returns an array with two elements, the first is an array of parts in array a , and the second is an array of parts in array b .
diff_compare_table() , diff_longest_sequence() , String.fuzzymatch()
array(array(int)) diff_compare_table(array a, array b)
Returns an array which maps from index in a to corresponding indices in b .
> Array.diff_compare_table( ({ "a","b","c" }), ({ "b", "b", "c", "d", "b" }));
Result: ({
({ }),
({
0,
1,
4
}),
({
2
})
})
diff() , diff_longest_sequence() , String.fuzzymatch()
array(int) diff_longest_sequence(array a, array b)
Gives the longest sequence of indices in b that have corresponding values in the same order in a .
diff() , diff_compare_table() , String.fuzzymatch()
array(int) diff_dyn_longest_sequence(array a, array b)
Gives the longest sequence of indices in b that have corresponding values in the same order in a .
This function performs the same operation as diff_longest_sequence() , but uses a different algorithm, which in some rare cases might be faster (usually it's slower though).
diff_longest_sequence() , diff() , diff_compare_table() , String.fuzzymatch()
array uniq(array a)
Remove elements that are duplicates.
This function returns an copy of the array a with all duplicate values removed. The order of the values is kept in the result; it's always the first of several equal elements that is kept.
Elements are compared with `== . They are also hashed (see lfun::__hash for further details if the array contains objects).
array(mixed) splice(array(mixed) arr1, array(mixed) arr2, array(mixed) ... more_arrays)
Splice two or more arrays.
This means that the returned array has the first element in the first given array, then the first argument in next array and so on for all arrays. Then the second elements are added, etc.
`/() , `*() , `+() , `-() , everynth()
array(mixed) everynth(array(mixed) a, void|int n, void|int start)
Return an array with every n :th element of the array a .
If n is zero every other element will be returned.
splice() , `/()
array(array) transpose(array(array) matrix)
Takes an array of equally sized arrays (essentially a matrix of size M*N) and returns the transposed (N*M) version of it, where rows and columns are exchanged for one another.
| CLASS Array.Iterator |
An object of this class is returned by get_iterator() when called with an array.
get_iterator
inherit predef::Iterator : predef::Iterator
| Module Error |
object mkerror(mixed error)
Returns an Error object for any argument it receives. If the argument already is an Error object or is empty, it does nothing.
| CLASS Error.Generic |
Class for exception objects for errors of unspecified type.
string Error.Generic.error_message
The error message. It always ends with a newline ('\n')
character and it might be more than one line.
Code that catches and rethrows errors may extend this with more error information.
array(backtrace_frame|array(mixed)) Error.Generic.error_backtrace
The backtrace as returned by backtrace where the error occurred.
Code that catches and rethrows errors should ensure that this remains the same in the rethrown error.
array cast(string type)
Cast operator.
The only supported type to cast to is "array", which
generates an old-style error ({message (),
backtrace ()}).
array|string `[](int(0..1) index)
Index operator.
Simulates an array
| ||||||
The error message is always terminated with a newline.
backtrace()
string describe()
Return a readable error report that includes the backtrace.
string message()
Return a readable message describing the error. Normally simply returns error_message .
If you override this function then you should ensure that error_message is included in the returned message, since there might be code that catches your error objects, extends error_message with more info, and rethrows the error.
array backtrace()
Return the backtrace where the error occurred. Normally simply returns error_backtrace .
predef::backtrace()
string _sprintf()
int(0..1) _is_type(string t)
Claims that the error object is an array, for compatibility with old style error handling code.
void Error.Generic(string message, void|array(backtrace_frame|array(mixed)) backtrace)
| Module Thread |
inherit Thread : Thread
array(Thread.Thread) all_threads()
This function returns an array with the thread ids of all threads.
Thread()
void thread_set_concurrency(int concurrency)
Document this function
Thread.Thread this_thread()
This function returns the object that identifies this thread.
Thread()
| CLASS Thread.Fifo |
Fifo implements a fixed length first-in, first-out queue. A fifo is a queue of values and is often used as a stream of data between two threads.
Queue
inherit Condition : r_cond
inherit Condition : w_cond
inherit Mutex : lock
int size()
This function returns the number of elements currently in the fifo.
read() , write()
mixed read()
This function retrieves a value from the fifo. Values will be returned in the order they were written. If there are no values present in the fifo the current thread will sleep until some other thread writes one.
try_read() , read_array() , write()
mixed try_read()
This function retrieves a value from the fifo if there is any there. Values will be returned in the order they were written. If there are no values present in the fifo then UNDEFINED will be returned.
read()
array read_array()
This function returns all values in the fifo as an array. The values in the array will be in the order they were written. If there are no values present in the fifo the current thread will sleep until some other thread writes one.
read() , try_read_array()
array try_read_array()
This function returns all values in the fifo as an array but doesn't wait if there are no values there. The values in the array will be in the order they were written.
read_array()
int write(mixed value)
Append a value to the end of the fifo. If there is no more room in the fifo the current thread will sleep until space is available. The number of items in the queue after the write is returned.
read()
int try_write(mixed value)
Append a value to the end of the fifo. If there is no more room in the fifo then zero will be returned, otherwise the number of items in the fifo after the write is returned.
read()
void Thread.Fifo()
void Thread.Fifo(int size)
Create a fifo. If the optional size argument is present it sets how many values can be written to the fifo without blocking. The default size is 128.
| CLASS Thread.Queue |
Queue implements a queue, or a pipeline. The main difference between Queue and Fifo is that Queue will never block in write(), only allocate more memory.
Fifo
inherit Condition : r_cond
inherit Mutex : lock
int size()
This function returns the number of elements currently in the queue.
read() , write()
mixed read()
This function retrieves a value from the queue. Values will be returned in the order they were written. If there are no values present in the queue the current thread will sleep until some other thread writes one.
try_read() , write()
mixed try_read()
This function retrieves a value from the queue if there is any there. Values will be returned in the order they were written. If there are no values present in the fifo then UNDEFINED will be returned.
write()
array read_array()
This function returns all values in the queue as an array. The values in the array will be in the order they were written. If there are no values present in the queue the current thread will sleep until some other thread writes one.
read() , try_read_array()
array try_read_array()
This function returns all values in the queue as an array but doesn't wait if there are no values there. The values in the array will be in the order they were written.
read_array()
int write(mixed value)
This function puts a value last in the queue. If the queue is too small to hold the value it will be expanded to make room. The number of items in the queue after the write is returned.
read()
| CLASS Thread.Thread |
void Thread.Thread(function(mixed ... :void) f, mixed ... args)
This function creates a new thread which will run simultaneously to the rest of the program. The new thread will call the function f with the arguments args . When f returns the thread will cease to exist.
All Pike functions are 'thread safe' meaning that running a function at the same time from different threads will not corrupt any internal data in the Pike process.
The returned value will be the same as the return value of this_thread() for the new thread.
This function is only available on systems with POSIX or UNIX or WIN32 threads support.
Mutex , Condition , this_thread()
array(mixed) backtrace()
Returns the current call stack for the thread.
The result has the same format as for predef::backtrace() .
predef::backtrace()
int status()
Returns the status of the thread.
|
string _sprintf(int c)
Returns a string identifying the thread.
int id_number()
Returns an id number identifying the thread.
This function was added in Pike 7.2.204.
mixed wait()
Waits for the thread to complete, and then returns the value returned from the thread function.
void interrupt()
void interrupt(string msg)
Interrupt the thread with the message msg .
The argument msg is currently ignored.
Interrupts are asynchronous, and are currently not queued.
void kill()
Interrupt the thread, and terminate it.
Interrupts are asynchronous, and are currently not queued.
| CLASS Thread.Mutex |
Mutex is a class that implements mutual exclusion locks. Mutex locks are used to prevent multiple threads from simultaneously execute sections of code which access or change shared data. The basic operations for a mutex is locking and unlocking. If a thread attempts to lock an already locked mutex the thread will sleep until the mutex is unlocked.
This class is simulated when Pike is compiled without thread support, so it's always available.
In POSIX threads, mutex locks can only be unlocked by the same thread that locked them. In Pike any thread can unlock a locked mutex.
MutexKey lock()
MutexKey lock(int type)
This function attempts to lock the mutex. If the mutex is already locked by a different thread the current thread will sleep until the mutex is unlocked. The value returned is the 'key' to the lock. When the key is destructed or has no more references the mutex will automatically be unlocked.
The type argument specifies what lock() should do if the mutex is already locked by this thread:
|
If the mutex is destructed while it's locked or while threads are waiting on it, it will continue to exist internally until the last thread has stopped waiting and the last MutexKey has disappeared, but further calls to the functions in this class will fail as is usual for destructed objects.
Pike 7.4 and earlier destructed any outstanding lock when the mutex was destructed, but threads waiting in lock still got functioning locks as discussed above. This is inconsistent no matter how you look at it, so it was changed in 7.6. The old behavior is retained in compatibility mode for applications that explicitly destruct mutexes to unlock them.
trylock()
MutexKey trylock()
MutexKey trylock(int type)
This function performs the same operation as lock() , but if the mutex is already locked, it will return zero instead of sleeping until it's unlocked.
lock()
Thread.Thread current_locking_thread()
This mutex method returns the object that identifies the thread that has locked the mutex. 0 is returned if the mutex isn't locked.
Thread()
Thread.MutexKey current_locking_key()
This mutex method returns the key object currently governing the lock on this mutex. 0 is returned if the mutex isn't locked.
Thread()
| CLASS Thread.MutexKey |
Objects of this class are returned by Mutex()->lock() and Mutex()->trylock() . They are also passed as arguments to Condition()->wait() .
As long as they are held, the corresponding mutex will be locked.
The corresponding mutex will be unlocked when the object is destructed (eg by not having any references left).
Mutex , Condition
| CLASS Thread.Condition |
Implementation of condition variables.
Condition variables are used by threaded programs to wait for events happening in other threads.
Condition variables are only available on systems with thread support. The Condition class is not simulated otherwise, since that can't be done accurately without continuations.
Mutex
void wait(Thread.MutexKey mutex_key)
Wait for condition.
This function makes the current thread sleep until the condition variable is signalled. The argument should be a Thread.MutexKey object for a Thread.Mutex . It will be unlocked atomically before waiting for the signal and then relocked atomically when the signal is received.
The thread that sends the signal should have the mutex locked while sending it. Otherwise it's impossible to avoid races where signals are sent while the listener(s) haven't arrived to the wait calls yet.
In Pike 7.2 and earlier it was possible to call wait() without arguments. This possibility was removed in later versions since it unavoidably leads to programs with races and/or deadlocks.
Note also that any threads waiting on the condition will be waken up when it gets destructed.
Mutex->lock()
void signal()
signal() wakes up one of the threads currently waiting for the condition.
Sometimes more than one thread is woken up.
broadcast()
void broadcast()
broadcast() wakes up all threads currently waiting for this condition.
signal()
| CLASS Thread.Local |
Thread local variable storage.
This class allows you to have variables which are separate for each thread that uses it. It has two methods: get() and set() . A value stored in an instance of Local can only be retrieved by that same thread.
This class is simulated when Pike is compiled without thread support, so it's always available.
mixed get()
Get the thread local value.
This returns the value prevoiusly stored in the Local object by the set() method by this thread.
set()
mixed set(mixed value)
Set the thread local value.
This sets the value returned by the get method.
Calling this method does not affect the value returned by get() when it's called by another thread (ie multiple values can be stored at the same time, but only one value per thread).
This function returns its argument.
Note that the value set can only be retreived by the same thread.
get()
| Module Float |
constant Float.DIGITS_10
constant Float.MIN_10_EXP
constant Float.MAX_10_EXP
constant Float.MIN
constant Float.MAX
constant Float.EPSILON
These constants define the limits for floats on the current architecture:
The number of decimal digits that can be represented. Any number
with this many decimal digits can be stored in a float and
converted back to decimal form without change. DIGITS_10 is
not less than 6.
Limits of the exponent in decimal base. 10 raised to any number
within this range can be represented in normalized form.
MIN_10_EXP is not greater than -37. MAX_10_EXP is
not less than 37.
The smallest normalized float greater than zero. It's not
greater than 1e-37.
The largest finite float. It's not less than 1e37.
The difference between 1 and the smallest value greater than 1
that can be represented. It's not greater than 1e-5.
The size of the float type can be controlled when Pike is compiled
with the configure flags --with-double-precision and
--with-long-double-precision. The default is to use the
longest available float type that fits inside a pointer.
constant Float.FLOAT_PRECISION
constant Float.DOUBLE_PRECISION
constant Float.LONG_DOUBLE_PRECISION
Tells which C compiler float type that is used for Pike floats.
Only one of these constants will exist (with the value 1)
at runtime.
The float type of the C compiler is used.
The double type of the C compiler is used.
The long double type of the C compiler is used.
The float type can be controlled when Pike is compiled with the
configure flags --with-double-precision and
--with-long-double-precision. The default is to use the
longest available float type that fits inside a pointer.
int(0..1) isnan(float x)
Returns true if x is nan.
| Module Function |
mixed splice_call(array args, function f, mixed|void ... extra)
Calls the given function with the args array plus the optional extra arguments as its arguments and returns the result.
Most useful in conjunction with map , and particularly in combination
with sscanf with "...%{...%}..." scan strings (which indeed
was what it was invented for in the first place).
The first arguments the function f expects.
The function to apply the arguments on.
Optional extra arguments to send to f .
Whatever the supplied function f returns.
class Product(string name, string version) { string _sprintf() { return sprintf("Product(%s/%s)", name, version); } } map(({ ({ "pike", "7.1.11" }), ({ "whitefish", "0.1" }) }), Function.splice_call, Product); ({ /* 2 elements */ Product(pike/7.1.11), Product(whitefish/0.1) })
function Y(function f)
The dreaded fixpoint combinator "Y".
The Y combinator is useful when writing recursive lambdas. It converts a lambda that expects a self-reference as its first argument into one which can be called without this argument.
This example creates a lambda that computes the faculty function.
Function.Y(lambda(function f, int n) { return n>1? n*f(n-1) : 1; })
function curry(function f)
Partially evaluate a function call.
This function allows N parameters to be given to a function taking M parameters (N<=M), yielding a new function taking M-N parameters.
What is actually returned from this function is a function taking N parameters, and returning a function taking M-N parameters.
This example creates a function adding 7 to its argument.
Function.curry(`+)(7)
void call_callback(function f, mixed ... args)
Call a callback function, but send throws from the callback function (ie, errors) to master()->handle_error. Also accepts if f is zero (0) without error.
Functions.call_callback(the_callback,some,arguments);
equals
{ mixed err=catch { if (the_callback) the_callback(some,arguments); }; if (err) master()->handle_error(err); }
(Approximately, since call_callback also calls handle_error if 0 were thrown.)
string defined(function fun)
Returns a string with filename and linenumber where fun was defined.
Returns 0 (zero) when no line can be found, e.g. for
builtin functions and functions in destructed objects.
| Module GDK |
constant GDK.Atom
| CLASS GDK.Window |
a GDK.Window object.
NOIMG
inherit GDK.Drawable : Drawable
GDK.Window change_property(GDK.Atom property, GDK.Atom type, int mode, string data)
mode is one of GDK_PROP_MODE_APPEND , GDK_PROP_MODE_PREPEND and GDK_PROP_MODE_REPLACE
array children()
Returns an array of GDK.Window objects.
GDK.Window GDK.Window(GDK.Window parent, mapping|void attributes)
Not for non-experts. I promise.
GDK.Window delete_property(GDK.Atom a)
mapping get_geometry()
Returns ([ "x":xpos, "y":ypos, "width":width, "height":height, "depth":bits_per_pixel ])
mapping get_property(GDK.Atom atom, int|void offset, int|void delete_when_done)
Returns the value (as a string) of the specified property. The arguments are:
property: The property atom, as an example GDK.Atom.__SWM_VROOT offset (optional): The starting offset, in elements delete_when_done (optional): If set, the property will be deleted when it has been fetched.
Example usage: Find the 'virtual' root window (many window managers put large windows over the screen)
GDK.Window root = GTK.root_window();
array maybe=root->children()->
get_property(GDK.Atom.__SWM_VROOT)-({0});
if(sizeof(maybe))
root=GDK.Window( maybe[0]->data[0] );
int is_viewable()
Return 1 if the window is mapped.
int is_visible()
Return 1 if the window, or a part of the window, is visible right now.
GDK.Window lower()
Lower this window if the window manager allows that.
GDK.Window move_resize(int x, int y, int w, int h)
Move and resize the window in one call.
GDK.Window raise()
Raise this window if the window manager allows that.
GDK.Window set_background(GDK.Color to)
Set the background color or image. The argument is either a GDK.Pixmap or a GDK.Color object.
GDK.Window set_bitmap_cursor(GDK.Bitmap image, GDK.Bitmap mask, GDK.Color fg, GDK.Color bg, int xhot, int yhot)
xhot,yhot are the locations of the x and y hotspot relative to the upper left corner of the cursor image.
GDK.Window set_cursor(int new_cursor)
Change the window cursor.<table border="0" cellpadding="3" cellspacing="0"> CURS(GDK.Arrow) CURS(GDK.BasedArrowDown) CURS(GDK.BasedArrowUp) CURS(GDK.Boat) CURS(GDK.Bogosity) CURS(GDK.BottomLeftCorner) CURS(GDK.BottomRightCorner) CURS(GDK.BottomSide) CURS(GDK.BottomTee) CURS(GDK.BoxSpiral) CURS(GDK.CenterPtr) CURS(GDK.Circle) CURS(GDK.Clock) CURS(GDK.CoffeeMug) CURS(GDK.Cross) CURS(GDK.CrossReverse) CURS(GDK.Crosshair) CURS(GDK.DiamondCross) CURS(GDK.Dot) CURS(GDK.Dotbox) CURS(GDK.DoubleArrow) CURS(GDK.DraftLarge) CURS(GDK.DraftSmall) CURS(GDK.DrapedBox) CURS(GDK.Exchange) CURS(GDK.Fleur) CURS(GDK.Gobbler) CURS(GDK.Gumby) CURS(GDK.Hand1) CURS(GDK.Hand2) CURS(GDK.Heart) CURS(GDK.Icon) CURS(GDK.IronCross) CURS(GDK.LeftPtr) CURS(GDK.LeftSide) CURS(GDK.LeftTee) CURS(GDK.Leftbutton) CURS(GDK.LlAngle) CURS(GDK.LrAngle) CURS(GDK.Man) CURS(GDK.Middlebutton) CURS(GDK.Mouse) CURS(GDK.Pencil) CURS(GDK.Pirate) CURS(GDK.Plus) CURS(GDK.QuestionArrow) CURS(GDK.RightPtr) CURS(GDK.RightSide) CURS(GDK.RightTee) CURS(GDK.Rightbutton) CURS(GDK.RtlLogo) CURS(GDK.Sailboat) CURS(GDK.SbDownArrow) CURS(GDK.SbHDoubleArrow) CURS(GDK.SbLeftArrow) CURS(GDK.SbRightArrow) CURS(GDK.SbUpArrow) CURS(GDK.SbVDoubleArrow) CURS(GDK.Shuttle) CURS(GDK.Sizing) CURS(GDK.Spider) CURS(GDK.Spraycan) CURS(GDK.Star) CURS(GDK.Target) CURS(GDK.Tcross) CURS(GDK.TopLeftArrow) CURS(GDK.TopLeftCorner) CURS(GDK.TopRightCorner) CURS(GDK.TopSide) CURS(GDK.TopTee) CURS(GDK.Trek) CURS(GDK.UlAngle) CURS(GDK.Umbrella) CURS(GDK.UrAngle) CURS(GDK.Watch) CURS(GDK.Xterm) </table>
GDK.Window set_events(int events)
events is a bitwise or of one or more of the following constants: GDK.ExposureMask, GDK.PointerMotionMask, GDK.PointerMotion_HINTMask, GDK.ButtonMotionMask, GDK.Button1MotionMask, GDK.Button2MotionMask, GDK.Button3MotionMask, GDK.ButtonPressMask, GDK.ButtonReleaseMask, GDK.KeyPressMask, GDK.KeyReleaseMask, GDK.EnterNotifyMask, GDK.LeaveNotifyMask, GDK.FocusChangeMask, GDK.StructureMask, GDK.PropertyChangeMask, GDK.VisibilityNotifyMask, GDK.ProximityInMask, GDK.ProximityOutMask and GDK.AllEventsMask
GDK.Window set_icon(GDK.Pixmap pixmap, GDK.Bitmap mask, GDK.Window window)
Set the icon to the specified image (with mask) or the specified GDK.Window. It is up to the window manager to display the icon. Most window manager handles window and pixmap icons, but only a few can handle the mask argument. If you want a shaped icon, the only safe bet is a shaped window.
GDK.Window set_icon_name(string name)
Set the icon name to the specified string.
GDK.Window shape_combine_mask(GDK.Bitmap mask, int xoffset, int yoffset)
Set the shape of the widget, or, rather, it's window, to that of the supplied bitmap.
| CLASS GDK.Region |
GDK.Region GDK.Region()
Create a new (empty) region
NOIMG
GDK.Region destroy()
int equal(GDK.Region victim)
Return true if the region used as an argument is equal to the current region. Also available as a==b when a is a region.
GDK.Region intersect(GDK.Region victim)
Computes the intersection of the given region and the region. Also available as region & region
GDK.Region offset(int dx, int dy)
Offset(move) the region by dx,dy pixels.
int point_in(int x, int y)
Returns true if the given point resides in the given region
int rect_in(GDK.Rectangle r)
Returns true if the given rectangle resides inside the given region
GDK.Region shrink(int dx, int dy)
reduces the size of a region by a specified amount. Positive values shrink the size of the region, and negative values expand the region.
GDK.Region subtract(GDK.Region victim)
Computes the difference of the given region and the region. Also available as region - region
GDK.Region union(GDK.Region victim)
Computes the union of the given rectangle or region and the region. Also available as region | rectangle, region | region, region + region and region + rectangle.
GDK.Region xor(GDK.Region victim)
Computes the exlusive or of the given region and the region. Also available as region ^ region
| CLASS GDK.Drawable |
The GDK.Bitmap, GDK.Window and GDK.Pixmap classes are all GDK drawables.
This means that you can use the same set of functions to draw in them.
Pixmaps are offscreen drawables. They can be drawn upon with the standard drawing primitives, then copied to another drawable (such as a GDK.Window) with window->draw_pixmap(), set as the background for a window or widget, or otherwise used to show graphics (in a W(Pixmap), as an example). The depth of a pixmap is the number of bits per pixels. Bitmaps are simply pixmaps with a depth of 1. (That is, they are monochrome bitmaps - each pixel can be either on or off).
Bitmaps are mostly used as masks when drawing pixmaps, or as a shape for a GDK.Window or a W(Widget)
GDK.Drawable clear(int|void x, int|void y, int|void width, int|void height)
Either clears the rectangle defined by the arguments, of if no arguments are specified, the whole drawable.
GDK.Drawable copy_area(GDK.GC gc, int xdest, int ydest, GTK.Widget source, int xsource, int ysource, int width, int height)
Copies the rectangle defined by xsource,ysource and width,height from the source drawable, and places the results at xdest,ydest in the drawable in which this function is called.
GDK.Drawable draw_arc(GDK.GC gc, int filledp, int x1, int y1, int x2, int y2, int angle1, int angle2)
Draws a single circular or elliptical arc. Each arc is specified by a rectangle and two angles. The center of the circle or ellipse is the center of the rectangle, and the major and minor axes are specified by the width and height. Positive angles indicate counterclockwise motion, and negative angles indicate clockwise motion. If the magnitude of angle2 is greater than 360 degrees, it is truncated to 360 degrees.
GDK.Drawable draw_bitmap(GDK.GC gc, GDK.Bitmap bitmap, int xsrc, int ysrc, int xdest, int ydest, int width, int height)
Draw a GDK(Bitmap) in this drawable. NOTE: This drawable must be a bitmap as well. This will be fixed in GTK 1.3
GDK.Drawable draw_image(GDK.GC gc, GDK.Image image, int xsrc, int ysrc, int xdest, int ydest, int width, int height)
Draw the rectangle specified by xsrc,ysrc+width,height from the GDK(Image) at xdest,ydest in the destination drawable
GDK.Drawable draw_line(GDK.GC gc, int x1, int y1, int x2, int y2)
img_begin w = GTK.DrawingArea()->set_usize(100,100); delay: g = GDK.GC(w)->set_foreground( GDK.Color(255,0,0) ); delay: for(int x = 0; x<10; x++) w->draw_line(g,x*10,0,100-x*10,99); img_end
GDK.Drawable draw_pixmap(GDK.GC gc, GDK.Pixmap pixmap, int xsrc, int ysrc, int xdest, int ydest, int width, int height)
Draw the rectangle specified by xsrc,ysrc+width,height from the GDK(Pixmap) at xdest,ydest in the destination drawable
GDK.Drawable draw_point(GDK.GC gc, int x, int y)
img_begin w = GTK.DrawingArea()->set_usize(10,10); delay: g = GDK.GC(w)->set_foreground( GDK.Color(255,0,0) ); delay: for(int x = 0; x<10; x++) w->draw_point(g, x, x); img_end
GDK.Drawable draw_rectangle(GDK.GC gc, int filledp, int x1, int y1, int x2, int y2)
img_begin w = GTK.DrawingArea()->set_usize(100,100); delay: g = GDK.GC(w)->set_foreground( GDK.Color(255,0,0) ); delay: for(int x = 0; x<10; x++) w->draw_rectangle(g,0,x*10,0,100-x*10,99); img_end img_begin w = GTK.DrawingArea()->set_usize(100,100); delay: g = GDK.GC(w); delay: for(int x = 0; x<30; x++) { delay: g->set_foreground(GDK.Color(random(255),random(255),random(255)) ); delay: w->draw_rectangle(g,1,x*10,0,100-x*10,99); delay: } img_end
GDK.Drawable draw_text(GDK.GC gc, GDK.Font font, int x, int y, string text, int forcewide)
y is used as the baseline for the text. If forcewide is true, the string will be expanded to a wide string even if it is not already one. This is useful when writing text using either unicode or some other 16 bit font.
mapping get_geometry()
Get width, height position and depth of the drawable as a mapping.
([ "x":xpos, "y":ypos, "width":xsize, "height":ysize, "depth":bits_per_pixel ])
int xid()
int xsize()
Returns the width of the drawable specified in pixels
int ysize()
Returns the height of the drawable specified in pixels
| CLASS GDK.Bitmap |
A bitmap is a black and white pixmap. Most commonly used as masks for images, widgets and pixmaps.
NOIMG
inherit GDK.Drawable : Drawable
GDK.Bitmap GDK.Bitmap(int|Image.Image xsize_or_image, int|void ysize, string|void bitmap)
Create a new GDK.Bitmap object. Argument is either an Image.Image object, or {xsisze,ysize,xbitmapdata}.
GDK.Bitmap destroy()
Destructor. Destroys the bitmap. This will free the bitmap on the X-server.
GDK.Bitmap ref()
Add a reference
GDK.Bitmap unref()
Remove a reference
| CLASS GDK.Image |
A gdk (low level) image. Mainly used for W(Image) objects.
NOIMG
GDK.Image GDK.Image(int|void fast_mode, Image.Image|void image)
Create a new GDK.Image object. The firstargument is either 0, which indicates that you want a 'slow' image. If you use '1', you indicate that you want a 'fast' image. Fast images are stored in shared memory, and thus are not sent over any network. But please limit your usage of fast images, they use up a possibly limited system resource set. See the man page for shmget(2) for more information on the limits on shared segments on your system.
A 'fast' image will automatically revert back to 'slow' mode if no shared memory is available.
If the second argument is specified, it is the actual image data.
GDK.Image destroy()
Destructor. Destroys the image. Automatically called by pike when the object is destructed.
int get_pixel(int x, int y)
Get the pixel value of a pixel as a X-pixel value. It is usualy not very easy to convert this value to a rgb triple. See get_pnm.
string get_pnm()
Returns the data in the image as a pnm object. Currently, this is always a P6 (true color raw) image. This could change in the future. To get a pike image object do 'Image.PNM.decode( gdkimage->get_pnm() )'
GDK.Image grab(GTK.Widget widget, int xoffset, int yoffset, int width, int height)
Call this function to grab a portion of a widget (argument 1) to the image. Grabbing non-toplevel widgets may produce unexpected results. To get the size of a widget use ->xsize() and ->ysize(). To get the offset of the upper left corner of the widget, relative to it's X-window (this is what you want for the offset arguments), use ->xoffset() and ->yoffset().
GDK.Image set(Image.Image|int image_or_xsize, int|void ysize)
Call this to set this image to either the contents of a pike image or a blank image of a specified size.
GDK.Image set_pixel(int x, int y, int pixel)
Set the pixel value of a pixel. Please note that the pixel argument is a X-pixel value, which is not easily gotten from a RGB color. See get_pixel and set.
| CLASS GDK.GC |
A GC, or Graphics Context, is used for most low-level drawing operation.
As an example, the foreground color, background color and drawing function is stored in the GC.
NOIMG
GDK.GC GDK.GC(GTK.Widget context)
The argument is a either a W(Widget) or a GDK(Drawable) in which the gc will be valid.
GDK.GC destroy()
Free the gc, called automatically by pike when the object is destroyed.
mapping get_values()
Get all (or rather most) values from the GC.
GDK.GC set_background(GDK.Color color)
Set the background to the specified GDK.Color.
GDK.GC set_clip_mask(GDK.Bitmap mask)
Set the clip mask to the specified GDK.Bitmap
GDK.GC set_clip_origin(int x, int y)
Set the clip mask origin to the specified point.
GDK.GC set_font(GDK.Font font)
Set the font to the specified GDK.Font.
GDK.GC set_foreground(GDK.Color color)
Set the foreground to the specified GDK.Color.
GDK.GC set_function(int fun)
Set the function to the specified one. One of GDK.Xor, GDK.Invert and GDK.Copy.
GDK.GC set_subwindow(int draw_on_subwindows)
If set, anything drawn with this GC will draw on subwindows as well as the window in which the drawing is done.
| CLASS GDK.DragContext |
The drag context contains all information about the drag'n'drop connected to the signal to which it is an argument.
NOIMG
GDK.DragContext drag_abort(int time)
Abort the drag
GDK.DragContext drag_drop(int time)
GDK.DragContext drag_finish(int success, int del, int time)
If success is true, the drag succeded. If del is true, the source should be deleted. time is the current time.
GDK.DragContext drag_set_icon_default()
Use the default drag icon associated with the source widget.
GDK.DragContext drag_set_icon_pixmap(GDK.Pixmap p, GDK.Bitmap b, int hot_x, int hot_y)
Set the drag pixmap, and optionally mask. The hot_x and hot_y coordinates will be the location of the mouse pointer, relative to the upper left corner of the pixmap.
GDK.DragContext drag_set_icon_widget(GTK.Widget widget, int hot_x, int hot_y)
Set the drag widget. This is a widget that will be shown, and then dragged around by the user during this drag.
GDK.DragContext drag_status(int action, int time)
Setting action to -1 means use the suggested action
GDK.DragContext drop_reply(int ok, int time)
int get_action()
One of GDK_ACTION_ASK , GDK_ACTION_COPY , GDK_ACTION_DEFAULT , GDK_ACTION_LINK , GDK_ACTION_MOVE and GDK_ACTION_PRIVATE ;
int get_actions()
A bitwise or of one or more of GDK_ACTION_ASK , GDK_ACTION_COPY , GDK_ACTION_DEFAULT , GDK_ACTION_LINK , GDK_ACTION_MOVE and GDK_ACTION_PRIVATE ;
int get_is_source()
Is this application the source?
int get_protocol()
One of GDK_DRAG_PROTO_MOTIF , GDK_DRAG_PROTO_ROOTWIN and GDK_DRAG_PROTO_XDND
GTK.Widget get_source_widget()
Return the drag source widget.
int get_start_time()
The start time of this drag, as a unix time_t (seconds since 0:00 1/1 1970)
int get_suggested_action()
One of GDK_ACTION_ASK , GDK_ACTION_COPY , GDK_ACTION_DEFAULT , GDK_ACTION_LINK , GDK_ACTION_MOVE and GDK_ACTION_PRIVATE ;
| CLASS GDK.Color |
The GDK.Color object is used to represent a color. When you call GDK.Color(r,g,b) the color will be allocated from the X-server. The constructor can return an exception if there are no more colors to allocate. NOIMG
int blue()
Returns the blue color component.
GDK.Color GDK.Color(object|int color_or_r, int|void g, int|void b)
r g and b are in the range 0 to 255, inclusive. If color is specified, it should be an Image.Color object, and the only argument.
GDK.Color destroy()
Destroys the color object. Please note that this function does not free the color from the X-colormap (in case of pseudocolor) right now.
int green()
Returns the green color component.
Image.Color.Color image_color_object()
Return a Image.Color.Color instance. This gives better precision than the rgb function.
int pixel()
Returns the pixel value of the color. See GDK.Image->set_pixel.
int red()
Returns the red color component.
array rgb()
Returns the red green and blue color components as an array.
| CLASS GDK.Event |
mixed _index(string ind)
mixed cast(string to)
GDK.Event destroy()
| CLASS GDK.Pixmap |
This class creates a GDK.Pixmap from either an GDK.Image or Image.Image object (or a numeric ID, see your X-manual for XIDs). The GDK.Pixmap object can be used in a lot of different GTK widgets. The most notable is the W(Pixmap) widget.
NOIMG
inherit GDK.Drawable : Drawable
GDK.Pixmap GDK.Pixmap(int|object image)
Create a new GDK.Pixmap object. Argument is a GDK.Image object or a Image.Image object
GDK.Pixmap destroy()
Destructor. Destroys the pixmap.
GDK.Pixmap ref()
GDK.Pixmap set(GDK.Image image)
Argument is a GDK.Image object or an Image.Image object. It is much faster to use an gdkImage object, especially one allocated in shared memory. This is only an issue if you are going to change the contents of the pixmap often, toggling between a small number of images.
GDK.Pixmap unref()
| CLASS GDK.Rectangle |
mixed cast(string type)
Normally used like (mapping)rectangle or (array)rectangle.
GDK.Rectangle GDK.Rectangle(int x, int y, int width, int height)
Create a new rectangle
NOIMG
GDK.Rectangle destroy()
GDK.Rectangle set(int x, int y, int width, int height)
Set the upper left corner and the size of the rectangle.
| CLASS GDK.Font |
The GdkFont data type represents a font for drawing on the screen. These functions provide support for loading fonts, and also for determining the dimensions of characters and strings when drawn with a particular font.
Fonts in X are specified by a X Logical Font Description. The following description is considerably simplified. For definitive information about XLFD's see the X reference documentation. A X Logical Font Description (XLFD) consists of a sequence of fields separated (and surrounded by) '-' characters. For example, Adobe Helvetica Bold 12 pt, has the full description: "-adobe-helvetica-bold-r-normal--12-120-75-75-p-70-iso8859-1"
The fields in the XLFD are:
|
When specifying a font via a X logical Font Description, '*' can be used as a wildcard to match any portion of the XLFD. For instance, the above example could also be specified as "-*-helvetica-bold-r-normal--*-120-*-*-*-*-iso8859-1"
It is generally a good idea to use wildcards for any portion of the XLFD that your program does not care about specifically, since that will improve the chances of finding a matching font.
int char_width(int character)
Return the width, in pixels, of the specified character, if rendered with this font. The character can be between 0 and 65535, the character encoding is font specific.
GDK.Font GDK.Font(string|void font_name)
Create a new font object. The string is the font XLFD.
GDK.Font destroy()
Free the font, called automatically by pike when the object is destroyed.
| CLASS GDK._Atom |
An X-atom. You most likely want to use GDK.Atom.atom_name instead of GDK._Atom(name).
GDK._Atom GDK._Atom(string atom_name, int|void only_if_exists)
Create a new low-level atom. You should normally not call this function directly. Use GDK.Atom[name] instead of GDK._Atom(name,0).
string get_name()
Returns the name of the atom.
| Module Object |
$Id: Object.pmod,v 1.1 2005/02/09 16:35:50 mast Exp $
constant Object.DESTRUCT_EXPLICIT
constant Object.DESTRUCT_NO_REFS
constant Object.DESTRUCT_GC
constant Object.DESTRUCT_CLEANUP
Flags passed to lfun::destroy .
Object.DESTRUCT_EXPLICIT is 0 and
Object.DESTRUCT_CLEANUP is 1 for compatibility.
| Module GLU |
The GL Utilities module is a partial implementation of the GLU library. This module only contains functions that someone at some point actually needed to get his work done. If you need a GLU function that isn't in here, copy the C code from the GLU library (Mesa was used last time), tweak it so that it compiles as Pike code and then check it in into the CVS.
void gluLookAt(float eyex, float eyey, float eyez, float centerx, float centery, float centerz, float upx, float upy, float upz)
void gluLookAt(Math.Matrix eye, Math.Matrix center, Math.Matrix up)
gluLookAt creates a viewing matrix derived from an eye point, a reference point indicating the center of the scene, and an up vector. The matrix maps the reference point to the negative z axis and the eye point to the origin, so that, when a typical projection matrix is used, the center of the scene maps to the center of the viewport. Similarly, the direction described by the up vector projected onto the viewing plane is mapped to the positive y axis so that it points upward in the viewport. The up vector must not be parallel to the line of sight from the eye to the reference point.
The matrix generated by gluLookAt postmultiplies the current matrix.
The relation between the matrix objects and the float values are
Math.Matrix eye = Math.Matrix( ({ eyex, eyey, eyez }) );
GL.glFrustum , gluPerspective
void gluOrtho2D(float left, float right, float bottom, float top)
gluOrtho2D sets up a two-dimensional orthographic viewing region. This is equivalent to calling
glOrtho(left, right, bottom, top, -1.0, 1.0);
The GLU manual says glOrtho(a,b,c,d, 0, 1).
GL.glOrtho , gluPerspective
void gluPerspective(float fovy, float aspect, float zNear, float zFar)
gluPerspective specifies a viewing frustum into the world coordinate system. In general, the aspect ratio in gluPerspective should match the aspect ratio of the associated viewport. For example, aspect = 2.0 means the viewer's angle of view is twice as wide in x as it is in y. If the viewport is twice as wide as it is tall, it displays the image without distortion.
The matrix generated by gluPerspective is multipled by the current matrix, just as if GL.glMultMatrix were called with the generated matrix. To load the perspective matrix onto the current matrix stack instead, precede the call to gluPerspective with a call to GL.glLoadIdentity .
void gluPickMatrix(float x, float y, float width, float height, array(int) viewport)
gluPickMatrix creates a projection matrix that can be used to restrict drawing to a small region of the viewport. This is typically useful to determine what objects are being drawn near the cursor. Use gluPickMatrix to restrict drawing to a small region around the cursor. Then, enter selection mode (with GL.glRenderMode and rerender the scene. All primitives that would have been drawn near the cursor are identified and stored in the selection buffer.
The matrix created by gluPickMatrix is multiplied by the current matrix just as if GL.glMultMatrix is called with the generated matrix. To effectively use the generated pick matrix for picking, first call GL.glLoadIdentity to load an identity matrix onto the perspective matrix stack. Then call gluPickMatrix, and finally, call a command (such as gluPerspective ) to multiply the perspective matrix by the pick matrix.
When using gluPickMatrix to pick NURBS, be careful to turn off the NURBS property GLU_AUTO_LOAD_MATRIX. If GLU_AUTO_LOAD_MATRIX is not turned off, then any NURBS surface rendered is subdivided differently with the pick matrix than the way it was subdivided without the pick matrix.
The viewport is an array with four integers.
Does the NURB remark apply?
GL.glGet , gluLoadIdentity , gluMultMatrix , gluRenderMode , gluPerspective
array(float) gluProject(float objx, float objy, float objz, array(float) model, array(float) proj, array(int) viewport)
gluProject transforms the specified object coordinates into window coordinates using model , proj , and viewport . The result is returned in a three valued array.
| Module Mapping |
constant Mapping.delete
Alias for m_delete()
| CLASS Mapping.ShadowedMapping |
A mapping look-alike that overrides (ie shadows) another parent mapping.
The class implements most of the usual mapping operations.
protected mapping|ShadowedMapping Mapping.ShadowedMapping.parentvoid Mapping.ShadowedMapping(mapping|ShadowedMapping parent)
void Mapping.ShadowedMapping(mapping|ShadowedMapping parent, mapping|void shadow, int(0..1)|void modify_parent)
Mapping to be shadowed.
Initial shadow of parent .
Modifications should be done to parent rather than to shadow . If this is set, only entries that are already present in shadow can be modified by later operations.
| CLASS Mapping.Iterator |
An object of this class is returned by get_iterator() when called with a mapping.
get_iterator
inherit predef::Iterator : predef::Iterator
| Module Colors |
array(int(0..255)) rgb_to_hsv(array(int(0..255)) rgb)
array(int(0..255)) rgb_to_hsv(int(0..255) r, int(0..255) g, int(0..255) b)
This function returns the HSV value of the color described by the provided RGB value. It is essentially calling Image.Color.rgb(r,g,b)->hsv().
Colors.hsv_to_rgb() Image.Color.Color.hsv()
array(int(0..255)) hsv_to_rgb(array(int(0..255)) hsv)
array(int(0..255)) hsv_to_rgb(int(0..255) h, int(0..255) s, int(0..255) v)
This function returns the RGB value of the color described by the provided HSV value. It is essentially calling Image.Color.hsv(h,s,v)->rgb().
Colors.rgb_to_hsv() Image.Color.hsv()
array(int(0..100)) rgb_to_cmyk(array(int(0..255)) rgb)
array(int(0..100)) rgb_to_cmyk(int(0..255) r, int(0..255) g, int(0..255) b)
This function returns the CMYK value of the color described by the provided RGB value. It is essentially calling Image.Color.rgb(r,g,b)->cmyk().
Colors.cmyk_to_rgb() Image.Color.Color.cmyk()
array(int(0..255)) cmyk_to_rgb(array(int(0..100)) cmyk)
array(int(0..255)) cmyk_to_rgb(int(0..100) c, int(0..100) m, int(0..100) y, int(0..100) k)
This function return the RGB value of the color describe by the provided CMYK value. It is essentially calling Image.Color.cmyk(c,m,y,k)->rgb()
Colors.rgb_to_cmyk() Image.Color.cmyk()
array(int(0..255)) parse_color(string name, void|array(int) def)
This function returns the RGB values that corresponds to the color that is provided by name to the function. It is essentially calling Image.Color.guess() , but returns the default value (or black if none is provided) if it failes.
string color_name(array(int(0..255)) rgb)
Tries to find a name to color described by the provided RGB values. Partially an inverse function to Colors.parse_color() , although it can not find all the names that Colors.parse_color() can find RGB values for. Returns the colors rgb hex value prepended with "#" upon failure.
| Module Program |
array(program) all_inherits(program p)
Document this function.
array inherit_tree(program p)
Recursively builds a inheritance tree by fetching programs inheritance lists.
Returns an array with programs or arrays as elements.
> class a{} > class b{} > class c{ inherit a; } > class d{ inherit b; inherit c; } > Program.inherit_tree(d); Result: ({ /* 3 elements */ d, ({ /* 1 element */ program }), ({ /* 2 elements */ c, ({ /* 1 element */ program }) }) })
array(program) inherit_list(program p)
Returns an array with the programs that p has inherited.
int implements(program prog, program api)
Returns 1 if prog implements api .
int inherits(program child, program parent)
Returns 1 if child has inherited parent .
string defined(program p)
Returns a string with filename and linenumber describing where the program p was defined.
The returned string is of the format "filename:linenumber".
If it cannot be determined where the program was defined, 0
(zero) will be returned.
| Module GL |
Not implemented OpenGL methods:
|
void glAccum(int op, float value)
The accumulation buffer is an extended-range color buffer. Images are not rendered into it. Rather, images rendered into one of the color buffers are added to the contents of the accumulation buffer after rendering. Effects such as antialiasing (of points, lines, and polygons), motion blur, and depth of field can be created by accumulating images generated with different transformation matrices.
Each pixel in the accumulation buffer consists of red, green, blue, and alpha values. The number of bits per component in the accumulation buffer depends on the implementation. You can examine this number by calling glGetIntegerv four times, with arguments GL_ACCUM_RED_BITS , GL_ACCUM_GREEN_BITS , GL_ACCUM_BLUE_BITS , and GL_ACCUM_ALPHA_BITS . Regardless of the number of bits per component, the range of values stored by each component is [-1, 1]. The accumulation buffer pixels are mapped one-to-one with frame buffer pixels.
glAccum operates on the accumulation buffer. The first argument, op, is a symbolic constant that selects an accumulation buffer operation. The second argument, value, is a floating-point value to be used in that operation. Five operations are specified: GL_ACCUM , GL_LOAD , GL_ADD , GL_MULT , and GL_RETURN .
All accumulation buffer operations are limited to the area of the current scissor box and applied identically to the red, green, blue, and alpha components of each pixel. If a glAccum operation results in a value outside the range [-1, 1], the contents of an accumulation buffer pixel component are undefined.
The operations are as follows:
|
To clear the accumulation buffer, call glClearAccum with R, G, B, and A values to set it to, then call glClear with the accumulation buffer enabled.
Specifies the accumulation buffer operation. Symbolic constants GL_ACCUM , GL_LOAD , GL_ADD , GL_MULT , and GL_RETURN are accepted.
Specifies a floating-point value used in the accumulation buffer operation. op determines how value is used.
GL_INVALID_ENUM is generated if op is not an accepted value.
GL_INVALID_OPERATION is generated if there is no accumulation buffer.
GL_INVALID_OPERATION is generated if glAccum is executed between the execution of glBegin and the corresponding execution of glEnd .
void glAlphaFunc(int func, float ref)
The alpha test discards fragments depending on the outcome of a comparison between an incoming fragment's alpha value and a constant reference value. glAlphaFunc specifies the reference value and the comparison function. The comparison is performed only if alpha testing is enabled. By default, it is not enabled. (See glEnable and glDisable of GL_ALPHA_TEST .)
func and ref specify the conditions under which the pixel is drawn. The incoming alpha value is compared to ref using the function specified by func. If the value passes the comparison, the incoming fragment is drawn if it also passes subsequent stencil and depth buffer tests. If the value fails the comparison, no change is made to the frame buffer at that pixel location. The comparison functions are as follows:
|
glAlphaFunc operates on all pixel write operations, including those resulting from the scan conversion of points, lines, polygons, and bitmaps, and from pixel draw and copy operations. glAlphaFunc does not affect screen clear operations.
Specifies the alpha comparison function. Symbolic constants GL_NEVER , GL_LESS , GL_EQUAL , GL_LEQUAL , GL_GREATER , GL_NOTEQUAL , GL_GEQUAL , and GL_ALWAYS are accepted. The initial value is GL_ALWAYS .
Specifies the reference value that incoming alpha values are compared to. This value is clamped to the range 0 through 1, where 0 represents the lowest possible alpha value and 1 the highest possible value. The initial reference value is 0.
GL_INVALID_ENUM is generated if func is not an accepted value.
GL_INVALID_OPERATION is generated if glAlphaFunc is executed between the execution of glBegin and the corresponding execution of glEnd .
void glArrayElement(int i)
glArrayElement commands are used within glBegin /glEnd pairs to specify vertex and attribute data for point, line, and polygon primitives. If GL_VERTEX_ARRAY is enabled when glArrayElement is called, a single vertex is drawn, using vertex and attribute data taken from location i of the enabled arrays. If GL_VERTEX_ARRAY is not enabled, no drawing occurs but the attributes corresponding to the enabled arrays are modified.
Use glArrayElement to construct primitives by indexing vertex data, rather than by streaming through arrays of data in first-to-last order. Because each call specifies only a single vertex, it is possible to explicitly specify per-primitive attributes such as a single normal per individual triangle.
Changes made to array data between the execution of glBegin and the corresponding execution of glEnd may affect calls to glArrayElement that are made within the same glBegin /glEnd period in non-sequential ways. That is, a call to
glArrayElement that precedes a change to array data may access the changed data, and a call that follows a change to array data may access original data.
Specifies an index into the enabled vertex data arrays.
void glBindTexture(int target, int texture)
glBindTexture lets you create or use a named texture. Calling glBindTexture with
target set to GL_TEXTURE_1D or GL_TEXTURE_2D and texture set to the name of the newtexture binds the texture name to the target. When a texture is bound to a target, the previous binding for that target is automatically broken.
Texture names are unsigned integers. The value zero is reserved to represent the default texture for each texture target. Texture names and the corresponding texture contents are local to the shared display-list space (see glXCreateContext ) of the current GL rendering context; two rendering contexts share texture names only if they also share display lists.
You may use glGenTextures to generate a set of new texture names.
When a texture is first bound, it assumes the dimensionality of its target: A texture first bound to GL_TEXTURE_1D becomes 1-dimensional and a texture first bound to GL_TEXTURE_2D becomes 2-dimensional. The state of a 1-dimensional texture immediately after it is first bound is equivalent to the state of the default GL_TEXTURE_1D at GL initialization, and similarly for 2-dimensional textures.
While a texture is bound, GL operations on the target to which it is bound affect the bound texture, and queries of the target to which it is bound return state from the bound texture. If texture mapping of the dimensionality of the target to which a texture is bound is active, the bound texture is used. In effect, the texture targets become aliases for the textures currently bound to them, and the texture name zero refers to the default textures that were bound to them at initialization.
A texture binding created with glBindTexture remains active until a different texture is bound to the same target, or until the bound texture is deleted with glDeleteTextures .
Once created, a named texture may be re-bound to the target of the matching dimensionality as often as needed. It is usually much faster to use glBindTexture to bind an existing named texture to one of the texture targets than it is to reload the texture image using glTexImage1D or glTexImage2D . For additional control over performance, use glPrioritizeTextures .
glBindTexture is included in display lists.
Specifies the target to which the texture is bound. Must be either GL_TEXTURE_1D or GL_TEXTURE_2D .
Specifies the name of a texture.
GL_INVALID_ENUM is generated if target is not one of the allowable values.
GL_INVALID_OPERATION is generated if texture has a dimensionality which doesn't match that of target.
GL_INVALID_OPERATION is generated if glBindTexture is executed between the execution of glBegin and the corresponding execution of glEnd .
void glBlendFunc(int sfactor, int dfactor)
In RGBA mode, pixels can be drawn using a function that blends the incoming (source) RGBA values with the RGBA values that are already in the frame buffer (the destination values). Blending is initially disabled. Use glEnable and glDisable with argument GL_BLEND to enable and disable blending.
glBlendFunc defines the operation of blending when it is enabled. sfactor specifies which of nine methods is used to scale the source color components. dfactor specifies which of eight methods is used to scale the destination color components. The eleven possible methods are described in the following table. Each method defines four scale factors, one each for red, green, blue, and alpha.
In the table and in subsequent equations, source and destination color components are referred to as (R sub s , G sub s , B sub s , A sub s ) and (R sub d , G sub d , B sub d , A sub d ). They are understood to have integer values between 0 and (k sub R , k sub G , k sub B , k sub A ), where
.RS .ce k sub c ~=~ 2 sup m sub c - 1 .RE
and (m sub R , m sub G , m sub B , m sub A ) is the number of red, green, blue, and alpha bitplanes.
Source and destination scale factors are referred to as (s sub R , s sub G , s sub B , s sub A ) and (d sub R , d sub G , d sub B , d sub A ). The scale factors described in the table, denoted (f sub R , f sub G , f sub B , f sub A ), represent either source or destination factors. All scale factors have range [0,1].
.TS center box ; ci | ci c | c . parameter (f sub R , ~~ f sub G , ~~ f sub B , ~~ f sub A ) = GL_ZERO (0, ~0, ~0, ~0 ) GL_ONE (1, ~1, ~1, ~1 ) GL_SRC_COLOR (R sub s / k sub R , ~G sub s / k sub G , ~B sub s / k sub B , ~A sub s / k sub A ) GL_ONE_MINUS_SRC_COLOR (1, ~1, ~1, ~1 ) ~-~ (R sub s / k sub R , ~G sub s / k sub G , ~B sub s / k sub B , ~A sub s / k sub A ) GL_DST_COLOR (R sub d / k sub R , ~G sub d / k sub G , ~B sub d / k sub B , ~A sub d / k sub A ) GL_ONE_MINUS_DST_COLOR (1, ~1, ~1, ~1 ) ~-~ (R sub d / k sub R , ~G sub d / k sub G , ~B sub d / k sub B , ~A sub d / k sub A ) GL_SRC_ALPHA (A sub s / k sub A , ~A sub s / k sub A , ~A sub s / k sub A , ~A sub s / k sub A ) GL_ONE_MINUS_SRC_ALPHA (1, ~1, ~1, ~1 ) ~-~ (A sub s / k sub A , ~A sub s / k sub A , ~A sub s / k sub A , ~A sub s / k sub A ) GL_DST_ALPHA (A sub d / k sub A , ~A sub d / k sub A , ~A sub d / k sub A , ~A sub d / k sub A ) GL_ONE_MINUS_DST_ALPHA (1, ~1, ~1, ~1 ) ~-~ (A sub d / k sub A , ~A sub d / k sub A , ~A sub d / k sub A , ~A sub d / k sub A ) GL_SRC_ALPHA_SATURATE (i, ~i, ~i, ~1 ) .TE .sp In the table,
.RS .nf
i ~=~ min (A sub s , ~k sub A - A sub d ) ~/~ k sub A .fi .RE
To determine the blended RGBA values of a pixel when drawing in RGBA mode, the system uses the following equations:
.RS .nf
R sub d ~=~ min ( k sub R , ~~ R sub s s sub R + R sub d d sub R ) G sub d ~=~ min ( k sub G , ~~ G sub s s sub G + G sub d d sub G ) B sub d ~=~ min ( k sub B , ~~ B sub s s sub B + B sub d d sub B ) A sub d ~=~ min ( k sub A , ~~ A sub s s sub A + A sub d d sub A ) .fi .RE
Despite the apparent precision of the above equations, blending arithmetic is not exactly specified, because blending operates with imprecise integer color values. However, a blend factor that should be equal to 1 is guaranteed not to modify its multiplicand, and a blend factor equal to 0 reduces its multiplicand to 0. For example, when sfactor is GL_SRC_ALPHA , dfactor is GL_ONE_MINUS_SRC_ALPHA , and A sub s is equal to k sub A, the equations reduce to simple replacement:
.RS .nf
R sub d ~=~ R sub s G sub d ~=~ G sub s B sub d ~=~ B sub s A sub d ~=~ A sub s .fi .RE
Specifies how the red, green, blue, and alpha source blending factors are computed. Nine symbolic constants are accepted: GL_ZERO , GL_ONE , GL_DST_COLOR , GL_ONE_MINUS_DST_COLOR , GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA , GL_DST_ALPHA , GL_ONE_MINUS_DST_ALPHA , and GL_SRC_ALPHA_SATURATE . The initial value is GL_ONE .
Specifies how the red, green, blue, and alpha destination blending factors are computed. Eight symbolic constants are accepted: GL_ZERO , GL_ONE , GL_SRC_COLOR , GL_ONE_MINUS_SRC_COLOR , GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA , GL_DST_ALPHA , and GL_ONE_MINUS_DST_ALPHA . The initial value is GL_ZERO .
GL_INVALID_ENUM is generated if either sfactor or dfactor is not an accepted value.
GL_INVALID_OPERATION is generated if glBlendFunc is executed between the execution of glBegin and the corresponding execution of glEnd .
void glCallList(int list)
glCallList causes the named display list to be executed. The commands saved in the display list are executed in order, just as if they were called without using a display list. If list has not been defined as a display list, glCallList is ignored.
glCallList can appear inside a display list. To avoid the possibility of infinite recursion resulting from display lists calling one another, a limit is placed on the nesting level of display lists during display-list execution. This limit is at least 64, and it depends on the implementation.
GL state is not saved and restored across a call to glCallList . Thus, changes made to GL state during the execution of a display list remain after execution of the display list is completed. Use glPushAttrib , glPopAttrib , glPushMatrix , and glPopMatrix to preserve GL state across glCallList calls.
Specifies the integer name of the display list to be executed.
void glClear(int mask)
glClear sets the bitplane area of the window to values previously selected by glClearColor , glClearIndex , glClearDepth , glClearStencil , and glClearAccum . Multiple color buffers can be cleared simultaneously by selecting more than one buffer at a time using glDrawBuffer .
The pixel ownership test, the scissor test, dithering, and the buffer writemasks affect the operation of glClear . The scissor box bounds the cleared region. Alpha function, blend function, logical operation, stenciling, texture mapping, and depth-buffering are ignored by glClear .
glClear takes a single argument that is the bitwise OR of several values indicating which buffer is to be cleared.
The values are as follows:
|
The value to which each buffer is cleared depends on the setting of the clear value for that buffer.
Bitwise OR of masks that indicate the buffers to be cleared. The four masks are GL_COLOR_BUFFER_BIT , GL_DEPTH_BUFFER_BIT , GL_ACCUM_BUFFER_BIT , and GL_STENCIL_BUFFER_BIT .
GL_INVALID_VALUE is generated if any bit other than the four defined bits is set in mask.
GL_INVALID_OPERATION is generated if glClear is executed between the execution of glBegin and the corresponding execution of glEnd .
void glClearAccum(float|array(float) red, float|void green, float|void blue, float|void alpha)
glClearAccum specifies the red, green, blue, and alpha values used by glClear to clear the accumulation buffer.
Values specified by glClearAccum are clamped to the range [-1,1].
Specify the red, green, blue, and alpha values used when the accumulation buffer is cleared. The initial values are all 0.
GL_INVALID_OPERATION is generated if glClearAccum is executed between the execution of glBegin and the corresponding execution of glEnd .
void glClearColor(float|array(float) red, float|void green, float|void blue, float|void alpha)
glClearColor specifies the red, green, blue, and alpha values used by glClear to clear the color buffers. Values specified by glClearColor are clamped to the range [0,1].
Specify the red, green, blue, and alpha values used when the color buffers are cleared. The initial values are all 0.
GL_INVALID_OPERATION is generated if glClearColor is executed between the execution of glBegin and the corresponding execution of glEnd .
void glClearDepth(float depth)
glClearDepth specifies the depth value used by glClear to clear the depth buffer. Values specified by glClearDepth are clamped to the range [0,1].
Specifies the depth value used when the depth buffer is cleared. The initial value is 1.
GL_INVALID_OPERATION is generated if glClearDepth is executed between the execution of glBegin and the corresponding execution of glEnd .
void glClearIndex(float c)
glClearIndex specifies the index used by glClear to clear the color index buffers. c is not clamped. Rather, c is converted to a fixed-point value with unspecified precision to the right of the binary point. The integer part of this value is then masked with 2 sup m -1, where m is the number of bits in a color index stored in the frame buffer.
Specifies the index used when the color index buffers are cleared. The initial value is 0.
GL_INVALID_OPERATION is generated if glClearIndex is executed between the execution of glBegin and the corresponding execution of glEnd .
void glClearStencil(int s)
glClearStencil specifies the index used by glClear to clear the stencil buffer. s is masked with 2 sup m - 1, where m is the number of bits in the stencil buffer.
Specifies the index used when the stencil buffer is cleared. The initial value is 0.
GL_INVALID_OPERATION is generated if glClearStencil is executed between the execution of glBegin and the corresponding execution of glEnd .
void glColor(float|int red, float|int green, float|int blue, float|int|void alpha)
void glColor(array(float|int) rgb)
The GL stores both a current single-valued color index and a current four-valued RGBA color. If no alpha value has been give, 1.0 (full intensity) is implied.
Current color values are stored in floating-point format, with unspecified mantissa and exponent sizes. Unsigned integer color components, when specified, are linearly mapped to floating-point values such that the largest representable value maps to 1.0 (full intensity), and 0 maps to 0.0 (zero intensity). Signed integer color components, when specified, are linearly mapped to floating-point values such that the most positive representable value maps to 1.0, and the most negative representable value maps to -1.0. (Note that this mapping does not convert 0 precisely to 0.0.) Floating-point values are mapped directly.
Neither floating-point nor signed integer values are clamped to the range [0,1] before the current color is updated. However, color components are clamped to this range before they are interpolated or written into a color buffer.
Specify new red, green, and blue values for the current color.
Specifies a new alpha value for the current color.
void glColorMask(int red, int green, int blue, int alpha)
glColorMask specifies whether the individual color components in the frame buffer can or cannot be written. If red is GL_FALSE , for example, no change is made to the red component of any pixel in any of the color buffers, regardless of the drawing operation attempted.
Changes to individual bits of components cannot be controlled. Rather, changes are either enabled or disabled for entire color components.
Specify whether red, green, blue, and alpha can or cannot be written into the frame buffer. The initial values are all GL_TRUE , indicating that the color components can be written.
GL_INVALID_OPERATION is generated if glColorMask is executed between the execution of glBegin and the corresponding execution of glEnd .
void glColorMaterial(int face, int mode)
glColorMaterial specifies which material parameters track the current color. When GL_COLOR_MATERIAL is enabled, the material parameter or parameters specified by mode, of the material or materials specified by face, track the current color at all times.
To enable and disable GL_COLOR_MATERIAL , call glEnable and glDisable with argument GL_COLOR_MATERIAL . GL_COLOR_MATERIAL is initially disabled.
Specifies whether front, back, or both front and back material parameters should track the current color. Accepted values are GL_FRONT , GL_BACK , and GL_FRONT_AND_BACK . The initial value is GL_FRONT_AND_BACK .
Specifies which of several material parameters track the current color. Accepted values are GL_EMISSION , GL_AMBIENT , GL_DIFFUSE , GL_SPECULAR , and GL_AMBIENT_AND_DIFFUSE . The initial value is GL_AMBIENT_AND_DIFFUSE .
GL_INVALID_ENUM is generated if face or mode is not an accepted value.
GL_INVALID_OPERATION is generated if glColorMaterial is executed between the execution of glBegin and the corresponding execution of glEnd .
void glCopyPixels(int x, int y, int width, int height, int type)
glCopyPixels copies a screen-aligned rectangle of pixels from the specified frame buffer location to a region relative to the current raster position. Its operation is well defined only if the entire pixel source region is within the exposed portion of the window. Results of copies from outside the window, or from regions of the window that are not exposed, are hardware dependent and undefined.
x and y specify the window coordinates of the lower left corner of the rectangular region to be copied. width and height specify the dimensions of the rectangular region to be copied. Both width and height must not be negative.
Several parameters control the processing of the pixel data while it is being copied. These parameters are set with three commands: glPixelTransfer , glPixelMap , and glPixelZoom . This reference page describes the effects on glCopyPixels of most, but not all, of the parameters specified by these three commands.
glCopyPixels copies values from each pixel with the lower left-hand corner at (x + i, y + j) for 0\(<=i<width and 0\(<=j<height. This pixel is said to be the ith pixel in the jth row. Pixels are copied in row order from the lowest to the highest row, left to right in each row.
type specifies whether color, depth, or stencil data is to be copied. The details of the transfer for each data type are as follows:
|
The rasterization described thus far assumes pixel zoom factors of 1.0. If
glPixelZoom is used to change the x and y pixel zoom factors, pixels are converted to fragments as follows. If (x sub r, y sub r) is the current raster position, and a given pixel is in the ith location in the jth row of the source pixel rectangle, then fragments are generated for pixels whose centers are in the rectangle with corners at
.ce (x sub r + zoom sub x i, y sub r + zoom sub y j) .sp .5 .ce and .sp .5 .ce (x sub r + zoom sub x (i + 1), y sub r + zoom sub y ( j + 1 ))
where zoom sub x is the value of GL_ZOOM_X and zoom sub y is the value of GL_ZOOM_Y .
Specify the window coordinates of the lower left corner of the rectangular region of pixels to be copied.
Specify the dimensions of the rectangular region of pixels to be copied. Both must be nonnegative.
Specifies whether color values, depth values, or stencil values are to be copied. Symbolic constants GL_COLOR , GL_DEPTH , and GL_STENCIL are accepted.
GL_INVALID_ENUM is generated if type is not an accepted value.
GL_INVALID_VALUE is generated if either width or height is negative.
GL_INVALID_OPERATION is generated if type is GL_DEPTH and there is no depth buffer.
GL_INVALID_OPERATION is generated if type is GL_STENCIL and there is no stencil buffer.
GL_INVALID_OPERATION is generated if glCopyPixels is executed between the execution of glBegin and the corresponding execution of glEnd .
void glCopyTexImage1D(int target, int level, int internalFormat, int x, int y, int width, int border)
glCopyTexImage1D defines a one-dimensional texture image with pixels from the current GL_READ_BUFFER .
The screen-aligned pixel row with left corner at ("x", "y") and with a length of "width"~+~2~*~"border" defines the texture array at the mipmap level specified by level. internalFormat specifies the internal format of the texture array.
The pixels in the row are processed exactly as if glCopyPixels had been called, but the process stops just before final conversion. At this point all pixel component values are clamped to the range [0,\ 1] and then converted to the texture's internal format for storage in the texel array.
Pixel ordering is such that lower x screen coordinates correspond to lower texture coordinates.
If any of the pixels within the specified row of the current GL_READ_BUFFER are outside the window associated with the current rendering context, then the values obtained for those pixels are undefined.
Specifies the target texture. Must be GL_TEXTURE_1D .
Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image.
Specifies the internal format of the texture. Must be one of the following symbolic constants: GL_ALPHA , GL_ALPHA4 , GL_ALPHA8 , GL_ALPHA12 , GL_ALPHA16 , GL_LUMINANCE , GL_LUMINANCE4 , GL_LUMINANCE8 , GL_LUMINANCE12 , GL_LUMINANCE16 , GL_LUMINANCE_ALPHA , GL_LUMINANCE4_ALPHA4 , GL_LUMINANCE6_ALPHA2 , GL_LUMINANCE8_ALPHA8 , GL_LUMINANCE12_ALPHA4 , GL_LUMINANCE12_ALPHA12 , GL_LUMINANCE16_ALPHA16 , GL_INTENSITY , GL_INTENSITY4 , GL_INTENSITY8 , GL_INTENSITY12 , GL_INTENSITY16 , GL_RGB , GL_R3_G3_B2 , GL_RGB4 , GL_RGB5 , GL_RGB8 , GL_RGB10 , GL_RGB12 , GL_RGB16 , GL_RGBA , GL_RGBA2 , GL_RGBA4 , GL_RGB5_A1 , GL_RGBA8 , GL_RGB10_A2 , GL_RGBA12 , or GL_RGBA16 .
Specify the window coordinates of the left corner of the row of pixels to be copied.
Specifies the width of the texture image. Must be 0 or 2**n ~+~ 2*border for some integer n. The height of the texture image is 1.
Specifies the width of the border. Must be either 0 or 1.
GL_INVALID_ENUM is generated if target is not one of the allowable values.
GL_INVALID_VALUE is generated if level is less than 0. .P GL_INVALID_VALUE may be generated if level is greater than log sub 2 max, where max is the returned value of GL_MAX_TEXTURE_SIZE . .P GL_INVALID_VALUE is generated if internalFormat is not an allowable value.
GL_INVALID_VALUE is generated if width is less than 0 or greater than 2 + GL_MAX_TEXTURE_SIZE , or if it cannot be represented as 2 ** n ~+~ 2~*~("border") for some integer value of n.
GL_INVALID_VALUE is generated if border is not 0 or 1.
GL_INVALID_OPERATION is generated if glCopyTexImage1D is executed between the execution of glBegin and the corresponding execution of glEnd .
void glCopyTexImage2D(int target, int level, int internalFormat, int x, int y, int width, int height, int border)
glCopyTexImage2D defines a two-dimensional texture image with pixels from the current GL_READ_BUFFER .
The screen-aligned pixel rectangle with lower left corner at (x, y) and with a width of width~+~2~*~border and a height of height~+~2~*~border defines the texture array at the mipmap level specified by level. internalFormat specifies the internal format of the texture array.
The pixels in the rectangle are processed exactly as if glCopyPixels had been called, but the process stops just before final conversion. At this point all pixel component values are clamped to the range [0,1] and then converted to the texture's internal format for storage in the texel array.
Pixel ordering is such that lower x and y screen coordinates correspond to lower s and t texture coordinates.
If any of the pixels within the specified rectangle of the current GL_READ_BUFFER are outside the window associated with the current rendering context, then the values obtained for those pixels are undefined.
Specifies the target texture. Must be GL_TEXTURE_2D .
Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image.
Specifies the internal format of the texture. Must be one of the following symbolic constants: GL_ALPHA , GL_ALPHA4 , GL_ALPHA8 , GL_ALPHA12 , GL_ALPHA16 , GL_LUMINANCE , GL_LUMINANCE4 , GL_LUMINANCE8 , GL_LUMINANCE12 , GL_LUMINANCE16 , GL_LUMINANCE_ALPHA , GL_LUMINANCE4_ALPHA4 , GL_LUMINANCE6_ALPHA2 , GL_LUMINANCE8_ALPHA8 , GL_LUMINANCE12_ALPHA4 , GL_LUMINANCE12_ALPHA12 , GL_LUMINANCE16_ALPHA16 , GL_INTENSITY , GL_INTENSITY4 , GL_INTENSITY8 , GL_INTENSITY12 , GL_INTENSITY16 , GL_RGB , GL_R3_G3_B2 , GL_RGB4 , GL_RGB5 , GL_RGB8 , GL_RGB10 , GL_RGB12 , GL_RGB16 , GL_RGBA , GL_RGBA2 , GL_RGBA4 , GL_RGB5_A1 , GL_RGBA8 , GL_RGB10_A2 , GL_RGBA12 , or GL_RGBA16 .
Specify the window coordinates of the lower left corner of the rectangular region of pixels to be copied.
Specifies the width of the texture image. Must be 0 or 2**n ~+~ 2*border for some integer n.
Specifies the height of the texture image. Must be 0 or 2**m ~+~ 2*border for some integer m.
Specifies the width of the border. Must be either 0 or 1.
GL_INVALID_ENUM is generated if target is not GL_TEXTURE_2D .
GL_INVALID_VALUE is generated if level is less than 0. .P GL_INVALID_VALUE may be generated if level is greater than log sub 2 max, where max is the returned value of GL_MAX_TEXTURE_SIZE .
GL_INVALID_VALUE is generated if width or height is less than 0, greater than 2~+~GL_MAX_TEXTURE_SIZE , or if width or height cannot be represented as 2**k ~+~ 2~*~border for some integer k.
GL_INVALID_VALUE is generated if border is not 0 or 1.
GL_INVALID_VALUE is generated if internalFormat is not one of the allowable values.
GL_INVALID_OPERATION is generated if glCopyTexImage2D is executed between the execution of glBegin and the corresponding execution of glEnd .
void glCopyTexSubImage1D(int target, int level, int xoffset, int x, int y, int width)
glCopyTexSubImage1D replaces a portion of a one-dimensional texture image with pixels from the current GL_READ_BUFFER (rather than from main memory, as is the case for glTexSubImage1D ).
The screen-aligned pixel row with left corner at (x,\ y), and with length width replaces the portion of the texture array with x indices xoffset through "xoffset" ~+~ "width" ~-~ 1, inclusive. The destination in the texture array may not include any texels outside the texture array as it was originally specified.
The pixels in the row are processed exactly as if glCopyPixels had been called, but the process stops just before final conversion. At this point all pixel component values are clamped to the range [0,\ 1] and then converted to the texture's internal format for storage in the texel array.
It is not an error to specify a subtexture with zero width, but such a specification has no effect. If any of the pixels within the specified row of the current GL_READ_BUFFER are outside the read window associated with the current rendering context, then the values obtained for those pixels are undefined.
No change is made to the internalformat, width, or border parameters of the specified texture array or to texel values outside the specified subregion.
Specifies the target texture. Must be GL_TEXTURE_1D .
Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image.
Specifies the texel offset within the texture array.
Specify the window coordinates of the left corner of the row of pixels to be copied.
Specifies the width of the texture subimage.
GL_INVALID_ENUM is generated if target is not GL_TEXTURE_1D .
GL_INVALID_OPERATION is generated if the texture array has not been defined by a previous glTexImage1D or glCopyTexImage1D operation.
GL_INVALID_VALUE is generated if level is less than 0. .P GL_INVALID_VALUE may be generated if level>log sub 2 max, where max is the returned value of GL_MAX_TEXTURE_SIZE .
GL_INVALID_VALUE is generated if y ~<~ ~-b or if width ~<~ ~-b, where b is the border width of the texture array.
GL_INVALID_VALUE is generated if "xoffset" ~<~ ~-b, or ("xoffset"~+~"width") ~>~ (w-b), where w is the GL_TEXTURE_WIDTH , and b is the GL_TEXTURE_BORDER of the texture image being modified. Note that w includes twice the border width.
void glCopyTexSubImage2D(int target, int level, int xoffset, int yoffset, int x, int y, int width, int height)
glCopyTexSubImage2D replaces a rectangular portion of a two-dimensional texture image with pixels from the current GL_READ_BUFFER (rather than from main memory, as is the case for glTexSubImage2D ).
The screen-aligned pixel rectangle with lower left corner at (x,\ y) and with width width and height height replaces the portion of the texture array with x indices xoffset through xoffset~+~width~-~1, inclusive, and y indices yoffset through yoffset~+~height~-~1, inclusive, at the mipmap level specified by level.
The pixels in the rectangle are processed exactly as if glCopyPixels had been called, but the process stops just before final conversion. At this point, all pixel component values are clamped to the range [0,\ 1] and then converted to the texture's internal format for storage in the texel array.
The destination rectangle in the texture array may not include any texels outside the texture array as it was originally specified. It is not an error to specify a subtexture with zero width or height, but such a specification has no effect.
If any of the pixels within the specified rectangle of the current GL_READ_BUFFER are outside the read window associated with the current rendering context, then the values obtained for those pixels are undefined.
No change is made to the internalformat, width, height, or border parameters of the specified texture array or to texel values outside the specified subregion.
Specifies the target texture. Must be GL_TEXTURE_2D
Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image.
Specifies a texel offset in the x direction within the texture array.
Specifies a texel offset in the y direction within the texture array.
Specify the window coordinates of the lower left corner of the rectangular region of pixels to be copied.
Specifies the width of the texture subimage.
Specifies the height of the texture subimage.
GL_INVALID_ENUM is generated if target is not GL_TEXTURE_2D .
GL_INVALID_OPERATION is generated if the texture array has not been defined by a previous glTexImage2D or glCopyTexImage2D operation.
GL_INVALID_VALUE is generated if level is less than 0. .P GL_INVALID_VALUE may be generated if level is greater than log sub 2 max, where max is the returned value of GL_MAX_TEXTURE_SIZE .
GL_INVALID_VALUE is generated if x ~<~ ~-b or if y ~<~ ~-b, where b is the border width of the texture array.
GL_INVALID_VALUE is generated if "xoffset" ~<~ -b, (xoffset~+~width)~>~(w ~-~b), yoffset~<~ ~-b, or (yoffset~+~height)~>~(h ~-~b), where w is the GL_TEXTURE_WIDTH , h is the GL_TEXTURE_HEIGHT , and b is the GL_TEXTURE_BORDER of the texture image being modified. Note that w and h include twice the border width.
GL_INVALID_OPERATION is generated if glCopyTexSubImage2D is executed between the execution of glBegin and the corresponding execution of glEnd .
void glDeleteLists(int list, int range)
glDeleteLists causes a contiguous group of display lists to be deleted. list is the name of the first display list to be deleted, and range is the number of display lists to delete. All display lists \fId\fP with list \(<= \fId\fP \(<= list + range - 1 are deleted.
All storage locations allocated to the specified display lists are freed, and the names are available for reuse at a later time. Names within the range that do not have an associated display list are ignored. If range is 0, nothing happens.
Specifies the integer name of the first display list to delete.
Specifies the number of display lists to delete.
GL_INVALID_VALUE is generated if range is negative.
GL_INVALID_OPERATION is generated if glDeleteLists is executed between the execution of glBegin and the corresponding execution of glEnd .
void glDepthMask(int flag)
glDepthMask specifies whether the depth buffer is enabled for writing. If flag is GL_FALSE , depth buffer writing is disabled. Otherwise, it is enabled. Initially, depth buffer writing is enabled.
Specifies whether the depth buffer is enabled for writing. If flag is GL_FALSE , depth buffer writing is disabled. Otherwise, it is enabled. Initially, depth buffer writing is enabled.
GL_INVALID_OPERATION is generated if glDepthMask is executed between the execution of glBegin and the corresponding execution of glEnd .
void glDepthRange(float zNear, float zFar)
After clipping and division by w, depth coordinates range from -1 to 1, corresponding to the near and far clipping planes. glDepthRange specifies a linear mapping of the normalized depth coordinates in this range to window depth coordinates. Regardless of the actual depth buffer implementation, window coordinate depth values are treated as though they range from 0 through 1 (like color components). Thus, the values accepted by glDepthRange are both clamped to this range before they are accepted.
The setting of (0,1) maps the near plane to 0 and the far plane to 1. With this mapping, the depth buffer range is fully utilized.
Specifies the mapping of the near clipping plane to window coordinates. The initial value is 0.
Specifies the mapping of the far clipping plane to window coordinates. The initial value is 1.
GL_INVALID_OPERATION is generated if glDepthRange is executed between the execution of glBegin and the corresponding execution of glEnd .
void glDrawArrays(int mode, int first, int count)
glDrawArrays specifies multiple geometric primitives with very few subroutine calls. Instead of calling a GL procedure to pass each individual vertex, normal, texture coordinate, edge flag, or color, you can prespecify separate arrays of vertexes, normals, and colors and use them to construct a sequence of primitives with a single call to glDrawArrays .
When glDrawArrays is called, it uses count sequential elements from each enabled array to construct a sequence of geometric primitives, beginning with element first. mode specifies what kind of primitives are constructed, and how the array elements construct those primitives. If GL_VERTEX_ARRAY is not enabled, no geometric primitives are generated.
Vertex attributes that are modified by glDrawArrays have an unspecified value after glDrawArrays returns. For example, if GL_COLOR_ARRAY is enabled, the value of the current color is undefined after glDrawArrays executes. Attributes that aren't modified remain well defined.
Specifies what kind of primitives to render. Symbolic constants GL_POINTS , GL_LINE_STRIP , GL_LINE_LOOP , GL_LINES , GL_TRIANGLE_STRIP , GL_TRIANGLE_FAN , GL_TRIANGLES , GL_QUAD_STRIP , GL_QUADS , and GL_POLYGON are accepted.
Specifies the starting index in the enabled arrays.
Specifies the number of indices to be rendered.
GL_INVALID_ENUM is generated if mode is not an accepted value.
GL_INVALID_VALUE is generated if count is negative.
GL_INVALID_OPERATION is generated if glDrawArrays is executed between the execution of glBegin and the corresponding glEnd .
void glDrawPixels(object|mapping(string:object) width, object|mapping(string:object) height, object|mapping(string:object) format, object|mapping(string:object) type, array(object|mapping(string:object)) pixels)
glDrawPixels reads pixel data from memory and writes it into the frame buffer relative to the current raster position. Use glRasterPos to set the current raster position; use glGet with argument GL_CURRENT_RASTER_POSITION to query the raster position.
Several parameters define the encoding of pixel data in memory and control the processing of the pixel data before it is placed in the frame buffer. These parameters are set with four commands: glPixelStore , glPixelTransfer , glPixelMap , and glPixelZoom . This reference page describes the effects on glDrawPixels of many, but not all, of the parameters specified by these four commands.
Data is read from pixels as a sequence of signed or unsigned bytes, signed or unsigned shorts, signed or unsigned integers, or single-precision floating-point values, depending on type. Each of these bytes, shorts, integers, or floating-point values is interpreted as one color or depth component, or one index, depending on format. Indices are always treated individually. Color components are treated as groups of one, two, three, or four values, again based on format. Both individual indices and groups of components are referred to as pixels. If type is GL_BITMAP , the data must be unsigned bytes, and format must be either GL_COLOR_INDEX or GL_STENCIL_INDEX . Each unsigned byte is treated as eight 1-bit pixels, with bit ordering determined by GL_UNPACK_LSB_FIRST (see glPixelStore ).
widthtimesheight pixels are read from memory, starting at location pixels. By default, these pixels are taken from adjacent memory locations, except that after all width pixels are read, the read pointer is advanced to the next four-byte boundary. The four-byte row alignment is specified by glPixelStore with argument GL_UNPACK_ALIGNMENT , and it can be set to one, two, four, or eight bytes. Other pixel store parameters specify different read pointer advancements, both before the first pixel is read and after all width pixels are read. See the
glPixelStore reference page for details on these options.
The widthtimesheight pixels that are read from memory are each operated on in the same way, based on the values of several parameters specified by glPixelTransfer and glPixelMap . The details of these operations, as well as the target buffer into which the pixels are drawn, are specific to the format of the pixels, as specified by format. format can assume one of eleven symbolic values:
|
.RS .ce x sub n ~=~ x sub r ~+~ n ~ roman mod ~ "width" .sp .ce y sub n ~=~ y sub r ~+~ \(lf ~ n / "width" ~ \(rf .fi .sp .RE
where (x sub r , y sub r) is the current raster position. Only the pixel ownership test, the scissor test, and the stencil writemask affect these write operations.
|
.RS .ce x sub n ~=~ x sub r ~+~ n ~ roman mod ~ "width" .sp .ce y sub n ~=~ y sub r ~+~ \(lf ~ n / "width" ~ \(rf .ce 0 .sp .RE
where (x sub r , y sub r) is the current raster position. These pixel fragments are then treated just like the fragments generated by rasterizing points, lines, or polygons. Texture mapping, fog, and all the fragment operations are applied before the fragments are written to the frame buffer.
|
.RS .ce x sub n ~=~ x sub r ~+~ n ~ roman mod ~ "width" .sp .ce y sub n ~=~ y sub r ~+~ \(lf ~ n / "width" ~ \(rf .ce 0 .sp .RE
where (x sub r , y sub r) is the current raster position. These pixel fragments are then treated just like the fragments generated by rasterizing points, lines, or polygons. Texture mapping, fog, and all the fragment operations are applied before the fragments are written to the frame buffer.
|
The following table summarizes the meaning of the valid constants for the type parameter: .sp 2 .TS center box ; ci | ci c | c . type corresponding type = GL_UNSIGNED_BYTE unsigned 8-bit integer GL_BYTE signed 8-bit integer GL_BITMAP single bits in unsigned 8-bit integers GL_UNSIGNED_SHORT unsigned 16-bit integer GL_SHORT signed 16-bit integer GL_UNSIGNED_INT unsigned 32-bit integer GL_INT 32-bit integer GL_FLOAT single-precision floating-point .TE .sp
The rasterization described so far assumes pixel zoom factors of 1. If
glPixelZoom is used to change the x and y pixel zoom factors, pixels are converted to fragments as follows. If (x sub r, y sub r) is the current raster position, and a given pixel is in the nth column and mth row of the pixel rectangle, then fragments are generated for pixels whose centers are in the rectangle with corners at .sp .RS .ce (x sub r + zoom sub x n, y sub r + zoom sub y m) .sp .ce (x sub r + zoom sub x (n + 1), y sub r + zoom sub y ( m + 1 )) .ce 0 .sp .RE
where zoom sub x is the value of GL_ZOOM_X and zoom sub y is the value of GL_ZOOM_Y .
Specify the dimensions of the pixel rectangle to be written into the frame buffer.
Specifies the format of the pixel data. Symbolic constants GL_COLOR_INDEX , GL_STENCIL_INDEX , GL_DEPTH_COMPONENT , GL_RGBA , GL_RED , GL_GREEN , GL_BLUE , GL_ALPHA , GL_RGB , GL_LUMINANCE , and GL_LUMINANCE_ALPHA are accepted.
Specifies the data type for pixels. Symbolic constants GL_UNSIGNED_BYTE , GL_BYTE , GL_BITMAP , GL_UNSIGNED_SHORT , GL_SHORT , GL_UNSIGNED_INT , GL_INT , and GL_FLOAT are accepted.
Specifies a pointer to the pixel data.
GL_INVALID_VALUE is generated if either width or height is negative.
GL_INVALID_ENUM is generated if format or type is not one of the accepted values.
GL_INVALID_OPERATION is generated if format is GL_RED , GL_GREEN , GL_BLUE , GL_ALPHA , GL_RGB , GL_RGBA , GL_LUMINANCE , or GL_LUMINANCE_ALPHA , and the GL is in color index mode.
GL_INVALID_ENUM is generated if type is GL_BITMAP and format is not either GL_COLOR_INDEX or GL_STENCIL_INDEX .
GL_INVALID_OPERATION is generated if format is GL_STENCIL_INDEX and there is no stencil buffer.
GL_INVALID_OPERATION is generated if glDrawPixels is executed between the execution of glBegin and the corresponding execution of glEnd .
void glEdgeFlag(int flag)
Each vertex of a polygon, separate triangle, or separate quadrilateral specified between a glBegin /glEnd pair is marked as the start of either a boundary or nonboundary edge. If the current edge flag is true when the vertex is specified, the vertex is marked as the start of a boundary edge. Otherwise, the vertex is marked as the start of a nonboundary edge. glEdgeFlag sets the edge flag bit to GL_TRUE if flag is GL_TRUE , and to GL_FALSE otherwise.
The vertices of connected triangles and connected quadrilaterals are always marked as boundary, regardless of the value of the edge flag.
Boundary and nonboundary edge flags on vertices are significant only if GL_POLYGON_MODE is set to GL_POINT or GL_LINE . See glPolygonMode .
Specifies the current edge flag value, either GL_TRUE or GL_FALSE . The initial value is GL_TRUE .
Specifies a pointer to an array that contains a single boolean element, which replaces the current edge flag value.
void glEvalCoord(float|int|array(float|int) u, float|int|void v)
glEvalCoord evaluates enabled one-dimensional maps at argument u or two-dimensional maps using two domain values, u and v . To define a map, call glMap1 and glMap2 ; to enable and disable it, call glEnable and glDisable .
When one of the glEvalCoord commands is issued, all currently enabled maps of the indicated dimension are evaluated. Then, for each enabled map, it is as if the corresponding GL command had been issued with the computed value. That is, if GL_MAP1_INDEX or GL_MAP2_INDEX is enabled, a glIndex command is simulated. If GL_MAP1_COLOR_4 or GL_MAP2_COLOR_4 is enabled, a glColor command is simulated. If GL_MAP1_NORMAL or GL_MAP2_NORMAL is enabled, a normal vector is produced, and if any of GL_MAP1_TEXTURE_COORD_1 , GL_MAP1_TEXTURE_COORD_2 , GL_MAP1_TEXTURE_COORD_3 , GL_MAP1_TEXTURE_COORD_4 , GL_MAP2_TEXTURE_COORD_1 , GL_MAP2_TEXTURE_COORD_2 , GL_MAP2_TEXTURE_COORD_3 , or GL_MAP2_TEXTURE_COORD_4 is enabled, then an appropriate glTexCoord command is simulated.
For color, color index, normal, and texture coordinates the GL uses evaluated values instead of current values for those evaluations that are enabled, and current values otherwise, However, the evaluated values do not update the current values. Thus, if glVertex commands are interspersed with glEvalCoord commands, the color, normal, and texture coordinates associated with the glVertex commands are not affected by the values generated by the glEvalCoord commands, but only by the most recent glColor , glIndex , glNormal , and glTexCoord commands.
No commands are issued for maps that are not enabled. If more than one texture evaluation is enabled for a particular dimension (for example, GL_MAP2_TEXTURE_COORD_1 and GL_MAP2_TEXTURE_COORD_2 ), then only the evaluation of the map that produces the larger number of coordinates (in this case, GL_MAP2_TEXTURE_COORD_2 ) is carried out. GL_MAP1_VERTEX_4 overrides GL_MAP1_VERTEX_3 , and GL_MAP2_VERTEX_4 overrides GL_MAP2_VERTEX_3 , in the same manner. If neither a three- nor a four-component vertex map is enabled for the specified dimension, the glEvalCoord command is ignored.
If you have enabled automatic normal generation, by calling glEnable with argument GL_AUTO_NORMAL , glEvalCoord generates surface normals analytically, regardless of the contents or enabling of the GL_MAP2_NORMAL map. Let .sp .nf Pp Pp m = -- X -- Pu Pv .sp .fi
Then the generated normal n is
n = m over ~ over { || m || }
.sp
If automatic normal generation is disabled, the corresponding normal map GL_MAP2_NORMAL , if enabled, is used to produce a normal. If neither automatic normal generation nor a normal map is enabled, no normal is generated for glEvalCoord commands.
Specifies a value that is the domain coordinate u to the basis function defined in a previous glMap1 or glMap2 command.
Specifies a value that is the domain coordinate v to the basis function defined in a previous glMap2 command.
Specifies a pointer to an array containing either one or two domain coordinates. The first coordinate is u. The second coordinate is v.
void glEvalPoint(int|array(int) i, int|void j)
glMapGrid and glEvalMesh are used in tandem to efficiently generate and evaluate a series of evenly spaced map domain values. glEvalPoint can be used to evaluate a single grid point in the same gridspace that is traversed by glEvalMesh . Calling glEvalPoint is equivalent to calling .nf
glEvalCoord1(i . DELTA u + u ); 1 where
DELTA u = (u - u ) / n 2 1
and n, u , and u 1 2
.fi are the arguments to the most recent glMapGrid1 command. The one absolute numeric requirement is that if i~=~n, then the value computed from .nf i . DELTA u + u is exactly u . 1 2
.fi
In the two-dimensional case, glEvalPoint , let .nf DELTA u = (u - u )/n 2 1
DELTA v = (v - v )/m 2 1
where n, u , u , m, v , and v 1 2 1 2
.fi are the arguments to the most recent glMapGrid2 command. Then the glEvalPoint command is equivalent to calling .nf
glEvalCoord2(i . DELTA u + u , j . DELTA v + v ); 1 1
.fi The only absolute numeric requirements are that if i~=~n, then the value computed from .nf
i . DELTA u + u is exactly u , 1 2 .fi and if j~=~m, then the value computed from .nf
j cdot DELTA v + v is exactly v . 1 2
Specifies the integer value for grid domain variable i.
Specifies the integer value for grid domain variable j (glEvalPoint only).
void glFog(int pname, float|int|array(float|int) param)
Fog is initially disabled. While enabled, fog affects rasterized geometry, bitmaps, and pixel blocks, but not buffer clear operations. To enable and disable fog, call glEnable and glDisable with argument GL_FOG .
glFog assigns the value or values in params to the fog parameter specified by pname. The following values are accepted for pname:
|
Fog blends a fog color with each rasterized pixel fragment's posttexturing color using a blending factor f. Factor f is computed in one of three ways, depending on the fog mode. Let z be the distance in eye coordinates from the origin to the fragment being fogged. The equation for GL_LINEAR fog is .ce
.EQ f ~=~ {end ~-~ z} over {end ~-~ start} .EN
.RE
The equation for GL_EXP fog is .ce
.EQ f ~=~ e ** (-(density ~cdot~ z)) .EN
The equation for GL_EXP2 fog is .ce
.EQ f ~=~ e ** (-(density ~cdot~ z) ** 2) .EN
Regardless of the fog mode, f is clamped to the range [0,1] after it is computed. Then, if the GL is in RGBA color mode, the fragment's color C sub r is replaced by .sp .ce .EQ {C sub r} prime ~=~ f C sub r + (1 - f) C sub f .EN
In color index mode, the fragment's color index i sub r is replaced by .sp .ce .EQ {i sub r} prime ~=~ i sub r + (1 - f) i sub f .EN
Specifies a single-valued fog parameter. GL_FOG_MODE , GL_FOG_DENSITY , GL_FOG_START , GL_FOG_END , and GL_FOG_INDEX are accepted.
Specifies the value that pname will be set to.
Specifies a fog parameter. GL_FOG_MODE , GL_FOG_DENSITY , GL_FOG_START , GL_FOG_END , GL_FOG_INDEX , and GL_FOG_COLOR are accepted.
Specifies the value or values to be assigned to pname. GL_FOG_COLOR requires an array of four values. All other parameters accept an array containing only a single value.
GL_INVALID_ENUM is generated if pname is not an accepted value, or if pname is GL_FOG_MODE and params is not an accepted value.
GL_INVALID_VALUE is generated if pname is GL_FOG_DENSITY , and params is negative.
GL_INVALID_OPERATION is generated if glFog is executed between the execution of glBegin and the corresponding execution of glEnd .
void glFrustum(float left, float right, float bottom, float top, float zNear, float zFar)
glFrustum describes a perspective matrix that produces a perspective projection. The current matrix (see glMatrixMode ) is multiplied by this matrix and the result replaces the current matrix, as if glMultMatrix were called with the following matrix as its argument:
.sp 5 .ce .EQ down 130 {left ( ~~ matrix { ccol { {{2 ~ "zNear"} over {"right" - "left"}} above 0 above 0 above 0 } ccol { 0 above {{2 ~ "zNear"} over {"top" - "bottom"}} ~ above 0 above 0 } ccol { A ~~~~ above B ~~~~ above C ~~~~ above -1 ~~~~} ccol { 0 above 0 above D above 0} } ~~~ right )} .EN .sp .ce .EQ down 130 {A ~=~ {"right" + "left"} over {"right" - "left"}} .EN .sp .ce .EQ down 130 {B ~=~ {"top" + "bottom"} over {"top" - "bottom"}} .EN .sp .ce .EQ down 130 {C ~=~ -{{"zFar" + "zNear"} over {"zFar" - "zNear"}}} .EN .sp .ce .EQ down 130 {D ~=~ -{{2 ~ "zFar" ~ "zNear"} over {"zFar" - "zNear"}}} .EN .sp
Typically, the matrix mode is GL_PROJECTION , and (left, bottom, -zNear) and (right, top, -zNear) specify the points on the near clipping plane that are mapped to the lower left and upper right corners of the window, assuming that the eye is located at (0, 0, 0). -zFar specifies the location of the far clipping plane. Both zNear and zFar must be positive.
Use glPushMatrix and glPopMatrix to save and restore the current matrix stack.
Specify the coordinates for the left and right vertical clipping planes.
Specify the coordinates for the bottom and top horizontal clipping planes.
Specify the distances to the near and far depth clipping planes. Both distances must be positive.
GL_INVALID_VALUE is generated if zNear or zFar is not positive.
GL_INVALID_OPERATION is generated if glFrustum is executed between the execution of glBegin and the corresponding execution of glEnd .
int glGenLists(int range)
glGenLists has one argument, range. It returns an integer n such that range contiguous empty display lists, named n, n+1, ..., n+range -1, are created. If range is 0, if there is no group of range contiguous names available, or if any error is generated, no display lists are generated, and 0 is returned.
Specifies the number of contiguous empty display lists to be generated.
GL_INVALID_VALUE is generated if range is negative.
GL_INVALID_OPERATION is generated if glGenLists is executed between the execution of glBegin and the corresponding execution of glEnd .
int glGetError()
glGetError returns the value of the error flag. Each detectable error is assigned a numeric code and symbolic name. When an error occurs, the error flag is set to the appropriate error code value. No other errors are recorded until glGetError is called, the error code is returned, and the flag is reset to GL_NO_ERROR . If a call to glGetError returns GL_NO_ERROR , there has been no detectable error since the last call to glGetError , or since the GL was initialized.
To allow for distributed implementations, there may be several error flags. If any single error flag has recorded an error, the value of that flag is returned and that flag is reset to GL_NO_ERROR when glGetError is called. If more than one flag has recorded an error, glGetError returns and clears an arbitrary error flag value. Thus, glGetError should always be called in a loop, until it returns GL_NO_ERROR , if all error flags are to be reset.
Initially, all error flags are set to GL_NO_ERROR .
The following errors are currently defined:
|
When an error flag is set, results of a GL operation are undefined only if GL_OUT_OF_MEMORY has occurred. In all other cases, the command generating the error is ignored and has no effect on the GL state or frame buffer contents. If the generating command returns a value, it returns 0. If glGetError itself generates an error, it returns 0.
GL_INVALID_OPERATION is generated if glGetError is executed between the execution of glBegin and the corresponding execution of glEnd . In this case glGetError returns 0.
string glGetString(int name)
glGetString returns a pointer to a static string describing some aspect of the current GL connection. name can be one of the following:
|
Because the GL does not include queries for the performance characteristics of an implementation, some applications are written to recognize known platforms and modify their GL usage based on known performance characteristics of these platforms. Strings GL_VENDOR and GL_RENDERER together uniquely specify a platform. They do not change from release to release and should be used by platform-recognition algorithms.
Some applications want to make use of features that are not part of the standard GL. These features may be implemented as extensions to the standard GL. The GL_EXTENSIONS string is a space-separated list of supported GL extensions. (Extension names never contain a space character.)
The GL_VERSION string begins with a version number. The version number uses one of these forms:
major_number.minor_number
major_number.minor_number.release_number
Vendor-specific information may follow the version number. Its format depends on the implementation, but a space always separates the version number and the vendor-specific information.
All strings are null-terminated.
Specifies a symbolic constant, one of GL_VENDOR , GL_RENDERER , GL_VERSION , or GL_EXTENSIONS .
GL_INVALID_ENUM is generated if name is not an accepted value.
GL_INVALID_OPERATION is generated if glGetString is executed between the execution of glBegin and the corresponding execution of glEnd .
void glHint(int target, int mode)
Certain aspects of GL behavior, when there is room for interpretation, can be controlled with hints. A hint is specified with two arguments. target is a symbolic constant indicating the behavior to be controlled, and mode is another symbolic constant indicating the desired behavior. The initial value for each target is GL_DONT_CARE . mode can be one of the following:
|
Though the implementation aspects that can be hinted are well defined, the interpretation of the hints depends on the implementation. The hint aspects that can be specified with target, along with suggested semantics, are as follows:
|
Specifies a symbolic constant indicating the behavior to be controlled. GL_FOG_HINT , GL_LINE_SMOOTH_HINT , GL_PERSPECTIVE_CORRECTION_HINT , GL_POINT_SMOOTH_HINT , and GL_POLYGON_SMOOTH_HINT are accepted.
Specifies a symbolic constant indicating the desired behavior. GL_FASTEST , GL_NICEST , and GL_DONT_CARE are accepted.
GL_INVALID_ENUM is generated if either target or mode is not an accepted value.
GL_INVALID_OPERATION is generated if glHint is executed between the execution of glBegin and the corresponding execution of glEnd .
void glIndex(float|int c)
glIndex updates the current (single-valued) color index. It takes one argument, the new value for the current color index.
The current index is stored as a floating-point value. Integer values are converted directly to floating-point values, with no special mapping. The initial value is 1.
Index values outside the representable range of the color index buffer are not clamped. However, before an index is dithered (if enabled) and written to the frame buffer, it is converted to fixed-point format. Any bits in the integer portion of the resulting fixed-point value that do not correspond to bits in the frame buffer are masked out.
Specifies the new value for the current color index.
Specifies a pointer to a one-element array that contains the new value for the current color index.
void glIndexMask(int mask)
glIndexMask controls the writing of individual bits in the color index buffers. The least significant n bits of mask, where n is the number of bits in a color index buffer, specify a mask. Where a 1 (one) appears in the mask, it's possible to write to the corresponding bit in the color index buffer (or buffers). Where a 0 (zero) appears, the corresponding bit is write-protected.
This mask is used only in color index mode, and it affects only the buffers currently selected for writing (see glDrawBuffer ). Initially, all bits are enabled for writing.
Specifies a bit mask to enable and disable the writing of individual bits in the color index buffers. Initially, the mask is all 1's.
GL_INVALID_OPERATION is generated if glIndexMask is executed between the execution of glBegin and the corresponding execution of glEnd .
int glIsEnabled(int cap)
glIsEnabled returns GL_TRUE if cap is an enabled capability and returns GL_FALSE otherwise. Initially all capabilities except GL_DITHER are disabled; GL_DITHER is initially enabled.
The following capabilities are accepted for cap:
.TS lb lb l l l. Constant See _
GL_ALPHA_TEST glAlphaFunc GL_AUTO_NORMAL glEvalCoord GL_BLEND glBlendFunc , glLogicOp GL_CLIP_PLANE iglClipPlane GL_COLOR_ARRAY glColorPointer GL_COLOR_LOGIC_OP glLogicOp GL_COLOR_MATERIAL glColorMaterial GL_CULL_FACE glCullFace GL_DEPTH_TEST glDepthFunc , glDepthRange GL_DITHER glEnable GL_EDGE_FLAG_ARRAY glEdgeFlagPointer GL_FOG glFog GL_INDEX_ARRAY glIndexPointer GL_INDEX_LOGIC_OP glLogicOp GL_LIGHT iglLightModel , glLight GL_LIGHTING glMaterial , glLightModel , glLight GL_LINE_SMOOTH glLineWidth GL_LINE_STIPPLE glLineStipple GL_MAP1_COLOR_4 glMap1 , glMap2 GL_MAP2_TEXTURE_COORD_2 glMap2 GL_MAP2_TEXTURE_COORD_3 glMap2 GL_MAP2_TEXTURE_COORD_4 glMap2 GL_MAP2_VERTEX_3 glMap2 GL_MAP2_VERTEX_4 glMap2 GL_NORMAL_ARRAY glNormalPointer GL_NORMALIZE glNormal GL_POINT_SMOOTH glPointSize GL_POLYGON_SMOOTH glPolygonMode GL_POLYGON_OFFSET_FILL glPolygonOffset GL_POLYGON_OFFSET_LINE glPolygonOffset GL_POLYGON_OFFSET_POINT glPolygonOffset GL_POLYGON_STIPPLE glPolygonStipple GL_SCISSOR_TEST glScissor GL_STENCIL_TEST glStencilFunc , glStencilOp GL_TEXTURE_1D glTexImage1D GL_TEXTURE_2D glTexImage2D GL_TEXTURE_COORD_ARRAY glTexCoordPointer GL_TEXTURE_GEN_Q glTexGen GL_TEXTURE_GEN_R glTexGen GL_TEXTURE_GEN_S glTexGen GL_TEXTURE_GEN_T glTexGen GL_VERTEX_ARRAY glVertexPointer .TE
Specifies a symbolic constant indicating a GL capability.
GL_INVALID_ENUM is generated if cap is not an accepted value.
GL_INVALID_OPERATION is generated if glIsEnabled is executed between the execution of glBegin and the corresponding execution of glEnd .
int glIsList(int list)
glIsList returns GL_TRUE if list is the name of a display list and returns GL_FALSE otherwise.
Specifies a potential display-list name.
GL_INVALID_OPERATION is generated if glIsList is executed between the execution of glBegin and the corresponding execution of glEnd .
int glIsTexture(int texture)
glIsTexture returns GL_TRUE if texture is currently the name of a texture. If texture is zero, or is a non-zero value that is not currently the name of a texture, or if an error occurs, glIsTexture returns GL_FALSE .
Specifies a value that may be the name of a texture.
GL_INVALID_OPERATION is generated if glIsTexture is executed between the execution of glBegin and the corresponding execution of glEnd .
void glLight(int light, int pname, float|int|array(float|int) param)
glLight sets the values of individual light source parameters. light names the light and is a symbolic name of the form GL_LIGHT i, where 0 \(<= i < GL_MAX_LIGHTS . pname specifies one of ten light source parameters, again by symbolic name. params is either a single value or a pointer to an array that contains the new values.
To enable and disable lighting calculation, call glEnable and glDisable with argument GL_LIGHTING . Lighting is initially disabled. When it is enabled, light sources that are enabled contribute to the lighting calculation. Light source i is enabled and disabled using glEnable and glDisable with argument GL_LIGHT i.
The ten light parameters are as follows:
|
Specifies a light. The number of lights depends on the implementation, but at least eight lights are supported. They are identified by symbolic names of the form GL_LIGHT i where 0 \(<= i < GL_MAX_LIGHTS .
Specifies a single-valued light source parameter for light. GL_SPOT_EXPONENT , GL_SPOT_CUTOFF , GL_CONSTANT_ATTENUATION , GL_LINEAR_ATTENUATION , and GL_QUADRATIC_ATTENUATION are accepted.
Specifies the value that parameter pname of light source light will be set to.
Specifies a light. The number of lights depends on the implementation, but at least eight lights are supported. They are identified by symbolic names of the form GL_LIGHT i where 0 \(<= i < GL_MAX_LIGHTS .
Specifies a light source parameter for light. GL_AMBIENT , GL_DIFFUSE , GL_SPECULAR , GL_POSITION , GL_SPOT_CUTOFF , GL_SPOT_DIRECTION , GL_SPOT_EXPONENT , GL_CONSTANT_ATTENUATION , GL_LINEAR_ATTENUATION , and GL_QUADRATIC_ATTENUATION are accepted.
Specifies a pointer to the value or values that parameter pname of light source light will be set to.
GL_INVALID_ENUM is generated if either light or pname is not an accepted value.
GL_INVALID_VALUE is generated if a spot exponent value is specified outside the range [0,128], or if spot cutoff is specified outside the range [0,90] (except for the special value 180), or if a negative attenuation factor is specified.
GL_INVALID_OPERATION is generated if glLight is executed between the execution of glBegin and the corresponding execution of glEnd .
void glLightModel(int pname, float|int|array(float|int) param)
glLightModel sets the lighting model parameter. pname names a parameter and params gives the new value. There are three lighting model parameters:
|
In RGBA mode, the lighted color of a vertex is the sum of the material emission intensity, the product of the material ambient reflectance and the lighting model full-scene ambient intensity, and the contribution of each enabled light source. Each light source contributes the sum of three terms: ambient, diffuse, and specular. The ambient light source contribution is the product of the material ambient reflectance and the light's ambient intensity. The diffuse light source contribution is the product of the material diffuse reflectance, the light's diffuse intensity, and the dot product of the vertex's normal with the normalized vector from the vertex to the light source. The specular light source contribution is the product of the material specular reflectance, the light's specular intensity, and the dot product of the normalized vertex-to-eye and vertex-to-light vectors, raised to the power of the shininess of the material. All three light source contributions are attenuated equally based on the distance from the vertex to the light source and on light source direction, spread exponent, and spread cutoff angle. All dot products are replaced with 0 if they evaluate to a negative value.
The alpha component of the resulting lighted color is set to the alpha value of the material diffuse reflectance.
In color index mode, the value of the lighted index of a vertex ranges from the ambient to the specular values passed to glMaterial using GL_COLOR_INDEXES . Diffuse and specular coefficients, computed with a (.30, .59, .11) weighting of the lights' colors, the shininess of the material, and the same reflection and attenuation equations as in the RGBA case, determine how much above ambient the resulting index is.
Specifies a single-valued lighting model parameter. GL_LIGHT_MODEL_LOCAL_VIEWER and GL_LIGHT_MODEL_TWO_SIDE are accepted.
Specifies the value that param will be set to.
Specifies a lighting model parameter. GL_LIGHT_MODEL_AMBIENT , GL_LIGHT_MODEL_LOCAL_VIEWER , and GL_LIGHT_MODEL_TWO_SIDE are accepted.
Specifies a pointer to the value or values that params will be set to.
GL_INVALID_ENUM is generated if pname is not an accepted value.
GL_INVALID_OPERATION is generated if glLightModel is executed between the execution of glBegin and the corresponding execution of glEnd .
void glLineStipple(int factor, int pattern)
Line stippling masks out certain fragments produced by rasterization; those fragments will not be drawn. The masking is achieved by using three parameters: the 16-bit line stipple pattern pattern, the repeat count factor, and an integer stipple counter s.
Counter s is reset to 0 whenever glBegin is called, and before each line segment of a glBegin (GL_LINES )/glEnd sequence is generated. It is incremented after each fragment of a unit width aliased line segment is generated, or after each i fragments of an i width line segment are generated. The i fragments associated with count s are masked out if .sp .ce pattern bit (s ~/~ "factor") ~roman mod~ 16 .sp is 0, otherwise these fragments are sent to the frame buffer. Bit zero of pattern is the least significant bit.
Antialiased lines are treated as a sequence of 1 times width rectangles for purposes of stippling. Whether rectagle s is rasterized or not depends on the fragment rule described for aliased lines, counting rectangles rather than groups of fragments.
To enable and disable line stippling, call glEnable and glDisable with argument GL_LINE_STIPPLE . When enabled, the line stipple pattern is applied as described above. When disabled, it is as if the pattern were all 1's. Initially, line stippling is disabled.
Specifies a multiplier for each bit in the line stipple pattern. If factor is 3, for example, each bit in the pattern is used three times before the next bit in the pattern is used. factor is clamped to the range [1, 256] and defaults to 1.
Specifies a 16-bit integer whose bit pattern determines which fragments of a line will be drawn when the line is rasterized. Bit zero is used first; the default pattern is all 1's.
GL_INVALID_OPERATION is generated if glLineStipple is executed between the execution of glBegin and the corresponding execution of glEnd .
void glLineWidth(float width)
glLineWidth specifies the rasterized width of both aliased and antialiased lines. Using a line width other than 1 has different effects, depending on whether line antialiasing is enabled. To enable and disable line antialiasing, call glEnable and glDisable with argument GL_LINE_SMOOTH . Line antialiasing is initially disabled.
If line antialiasing is disabled, the actual width is determined by rounding the supplied width to the nearest integer. (If the rounding results in the value 0, it is as if the line width were 1.) If .nf | DELTA x | >= | DELTA y |, .fi i pixels are filled in each column that is rasterized, where i is the rounded value of width. Otherwise, i pixels are filled in each row that is rasterized.
If antialiasing is enabled, line rasterization produces a fragment for each pixel square that intersects the region lying within the rectangle having width equal to the current line width, length equal to the actual length of the line, and centered on the mathematical line segment. The coverage value for each fragment is the window coordinate area of the intersection of the rectangular region with the corresponding pixel square. This value is saved and used in the final rasterization step.
Not all widths can be supported when line antialiasing is enabled. If an unsupported width is requested, the nearest supported width is used. Only width 1 is guaranteed to be supported; others depend on the implementation. To query the range of supported widths and the size difference between supported widths within the range, call glGet with arguments GL_LINE_WIDTH_RANGE and GL_LINE_WIDTH_GRANULARITY .
Specifies the width of rasterized lines. The initial value is 1.
GL_INVALID_VALUE is generated if width is less than or equal to 0.
GL_INVALID_OPERATION is generated if glLineWidth is executed between the execution of glBegin and the corresponding execution of glEnd .
void glListBase(int base)
glCallLists specifies an array of offsets. Display-list names are generated by adding base to each offset. Names that reference valid display lists are executed; the others are ignored.
Specifies an integer offset that will be added to glCallLists offsets to generate display-list names. The initial value is 0.
GL_INVALID_OPERATION is generated if glListBase is executed between the execution of glBegin and the corresponding execution of glEnd .
void glLoadMatrix(array(array(float|int)) m)
glLoadMatrix replaces the current matrix with the one whose elements are specified by m. The current matrix is the projection matrix, modelview matrix, or texture matrix, depending on the current matrix mode (see glMatrixMode ).
The current matrix, M, defines a transformation of coordinates. For instance, assume M refers to the modelview matrix. If v ~=~ (v[0], v[1], v[2], v[3]) is the set of object coordinates of a vertex, and m points to an array of 16 single- or double-precision floating-point values m[0], m[1],. . .,m[15], then the modelview transformation M(v) does the following:
.ce .EQ down 130 {M(v) ~ = ~ {{ left ( matrix { ccol { ~m[0] above m[1] above m[2] above m[3] ~} ccol { ~m[4] above m[5] above m[6] above m[7] ~} ccol { ~m[8] above m[9] above m[10] above m[11] ~} ccol { ~m[12]~ above m[13]~ above m[14]~ above m[15]~} } right ) } ~~ times ~~ {left ( matrix { ccol { ~v[0]~ above ~v[1]~ above ~v[2]~ above ~v[3]~ } } right )} }} .EN
.sp
Where 'times' denotes matrix multiplication.
Projection and texture transformations are similarly defined.
Specifies a pointer to 16 consecutive values, which are used as the elements of a 4 times 4 column-major matrix.
GL_INVALID_OPERATION is generated if glLoadMatrix is executed between the execution of glBegin and the corresponding execution of glEnd .
void glLoadName(int name)
The name stack is used during selection mode to allow sets of rendering commands to be uniquely identified. It consists of an ordered set of unsigned integers. glLoadName causes name to replace the value on the top of the name stack, which is initially empty.
The name stack is always empty while the render mode is not GL_SELECT . Calls to glLoadName while the render mode is not GL_SELECT are ignored.
Specifies a name that will replace the top value on the name stack.
GL_INVALID_OPERATION is generated if glLoadName is called while the name stack is empty.
GL_INVALID_OPERATION is generated if glLoadName is executed between the execution of glBegin and the corresponding execution of glEnd .
void glMaterial(int face, int pname, float|int|array(float|int) param)
glMaterial assigns values to material parameters. There are two matched sets of material parameters. One, the front-facing set, is used to shade points, lines, bitmaps, and all polygons (when two-sided lighting is disabled), or just front-facing polygons (when two-sided lighting is enabled). The other set, back-facing, is used to shade back-facing polygons only when two-sided lighting is enabled. Refer to the glLightModel reference page for details concerning one- and two-sided lighting calculations.
glMaterial takes three arguments. The first, face, specifies whether the GL_FRONT materials, the GL_BACK materials, or both GL_FRONT_AND_BACK materials will be modified. The second, pname, specifies which of several parameters in one or both sets will be modified. The third, params, specifies what value or values will be assigned to the specified parameter.
Material parameters are used in the lighting equation that is optionally applied to each vertex. The equation is discussed in the glLightModel reference page. The parameters that can be specified using glMaterial , and their interpretations by the lighting equation, are as follows:
|
Specifies which face or faces are being updated. Must be one of GL_FRONT , GL_BACK , or GL_FRONT_AND_BACK .
Specifies the single-valued material parameter of the face or faces that is being updated. Must be GL_SHININESS .
Specifies the value that parameter GL_SHININESS will be set to.
Specifies which face or faces are being updated. Must be one of GL_FRONT , GL_BACK , or GL_FRONT_AND_BACK .
Specifies the material parameter of the face or faces that is being updated. Must be one of GL_AMBIENT , GL_DIFFUSE , GL_SPECULAR , GL_EMISSION , GL_SHININESS , GL_AMBIENT_AND_DIFFUSE , or GL_COLOR_INDEXES .
Specifies a pointer to the value or values that pname will be set to.
GL_INVALID_ENUM is generated if either face or pname is not an accepted value.
GL_INVALID_VALUE is generated if a specular exponent outside the range [0,128] is specified.
void glMultMatrix(array(array(float|int)) m)
glMultMatrix multiplies the current matrix with the one specified using m, and replaces the current matrix with the product.
The current matrix is determined by the current matrix mode (see glMatrixMode ). It is either the projection matrix, modelview matrix, or the texture matrix.
Points to 16 consecutive values that are used as the elements of a 4 times 4 column-major matrix.
GL_INVALID_OPERATION is generated if glMultMatrix is executed between the execution of glBegin and the corresponding execution of glEnd .
void glNewList(int list, int mode)
Display lists are groups of GL commands that have been stored for subsequent execution. Display lists are created with glNewList . All subsequent commands are placed in the display list, in the order issued, until glEndList is called.
glNewList has two arguments. The first argument, list, is a positive integer that becomes the unique name for the display list. Names can be created and reserved with glGenLists and tested for uniqueness with glIsList . The second argument, mode, is a symbolic constant that can assume one of two values:
|
Certain commands are not compiled into the display list but are executed immediately, regardless of the display-list mode. These commands are glColorPointer , glDeleteLists , glDisableClientState , glEdgeFlagPointer , glEnableClientState , glFeedbackBuffer , glFinish , glFlush , glGenLists , glIndexPointer , glInterleavedArrays , glIsEnabled , glIsList , glNormalPointer , glPopClientAttrib , glPixelStore , glPushClientAttrib , glReadPixels , glRenderMode , glSelectBuffer , glTexCoordPointer , glVertexPointer , and all of the glGet commands.
Similarly, glTexImage2D and glTexImage1D are executed immediately and not compiled into the display list when their first argument is GL_PROXY_TEXTURE_2D or GL_PROXY_TEXTURE_1D , respectively.
When glEndList is encountered, the display-list definition is completed by associating the list with the unique name list (specified in the glNewList command). If a display list with name list already exists, it is replaced only when glEndList is called.
Specifies the display-list name.
Specifies the compilation mode, which can be GL_COMPILE or GL_COMPILE_AND_EXECUTE .
GL_INVALID_VALUE is generated if list is 0.
GL_INVALID_ENUM is generated if mode is not an accepted value.
GL_INVALID_OPERATION is generated if glEndList is called without a preceding glNewList , or if glNewList is called while a display list is being defined.
GL_INVALID_OPERATION is generated if glNewList or glEndList is executed between the execution of glBegin and the corresponding execution of glEnd .
GL_OUT_OF_MEMORY is generated if there is insufficient memory to compile the display list. If the GL version is 1.1 or greater, no change is made to the previous contents of the display list, if any, and no other change is made to the GL state. (It is as if no attempt had been made to create the new display list.)
void glNormal(float|int|array(float|int) nx, float|int|void ny, float|int|void nz)
The current normal is set to the given coordinates whenever glNormal is issued. Byte, short, or integer arguments are converted to floating-point format with a linear mapping that maps the most positive representable integer value to 1.0, and the most negative representable integer value to -1.0.
Normals specified with glNormal need not have unit length. If normalization is enabled, then normals specified with glNormal are normalized after transformation. To enable and disable normalization, call glEnable and glDisable with the argument GL_NORMALIZE . Normalization is initially disabled.
Specify the x, y, and z coordinates of the new current normal. The initial value of the current normal is the unit vector, (0, 0, 1).
Specifies a pointer to an array of three elements: the x, y, and z coordinates of the new current normal.
void glOrtho(float left, float right, float bottom, float top, float zNear, float zFar)
glOrtho describes a transformation that produces a parallel projection. The current matrix (see glMatrixMode ) is multiplied by this matrix and the result replaces the current matrix, as if glMultMatrix were called with the following matrix as its argument: .sp .ce .EQ left ( matrix { ccol { {2 over {"right" - "left"}} above 0 above 0 above 0 } ccol { 0 above {2 over {"top" - "bottom"}} above 0 above 0 } ccol { 0 above 0 above {-2 over {"zFar" - "zNear"}} above 0 } ccol { {t sub x}~ above {t sub y}~ above {t sub z}~ above 1~ } } right ) .EN
where .ce .EQ t sub x ~=~ -{{"right" + "left"} over {"right" - "left"}} .EN
.ce .EQ t sub y ~=~ -{{"top" + "bottom"} over {"top" - "bottom"}} .EN
.ce .EQ t sub z ~=~ -{{"zFar" + "zNear"} over {"zFar" - "zNear"}} .EN
.RE
Typically, the matrix mode is GL_PROJECTION , and (left, bottom, -zNear) and (right, top, -zNear) specify the points on the near clipping plane that are mapped to the lower left and upper right corners of the window, respectively, assuming that the eye is located at (0, 0, 0). -zFar specifies the location of the far clipping plane. Both zNear and zFar can be either positive or negative.
Use glPushMatrix and glPopMatrix to save and restore the current matrix stack.
Specify the coordinates for the left and right vertical clipping planes.
Specify the coordinates for the bottom and top horizontal clipping planes.
Specify the distances to the nearer and farther depth clipping planes. These values are negative if the plane is to be behind the viewer.
GL_INVALID_OPERATION is generated if glOrtho is executed between the execution of glBegin and the corresponding execution of glEnd .
void glPassThrough(float token)
Feedback is a GL render mode. The mode is selected by calling glRenderMode with GL_FEEDBACK . When the GL is in feedback mode, no pixels are produced by rasterization. Instead, information about primitives that would have been rasterized is fed back to the application using the GL. See the glFeedbackBuffer reference page for a description of the feedback buffer and the values in it.
glPassThrough inserts a user-defined marker in the feedback buffer when it is executed in feedback mode. token is returned as if it were a primitive; it is indicated with its own unique identifying value: GL_PASS_THROUGH_TOKEN . The order of glPassThrough commands with respect to the specification of graphics primitives is maintained.
Specifies a marker value to be placed in the feedback buffer following a GL_PASS_THROUGH_TOKEN .
GL_INVALID_OPERATION is generated if glPassThrough is executed between the execution of glBegin and the corresponding execution of glEnd .
void glPixelZoom(float xfactor, float yfactor)
glPixelZoom specifies values for the x and y zoom factors. During the execution of glDrawPixels or glCopyPixels , if (xr , yr ) is the current raster position, and a given element is in the mth row and nth column of the pixel rectangle, then pixels whose centers are in the rectangle with corners at .sp .ce (xr ~+~ n cdot "xfactor", yr ~+~ m cdot "yfactor") .sp .ce (xr ~+~ (n+1) cdot "xfactor", yr ~+~ (m+1) cdot "yfactor") .sp are candidates for replacement. Any pixel whose center lies on the bottom or left edge of this rectangular region is also modified.
Pixel zoom factors are not limited to positive values. Negative zoom factors reflect the resulting image about the current raster position.
Specify the x and y zoom factors for pixel write operations.
GL_INVALID_OPERATION is generated if glPixelZoom is executed between the execution of glBegin and the corresponding execution of glEnd .
void glPointSize(float size)
glPointSize specifies the rasterized diameter of both aliased and antialiased points. Using a point size other than 1 has different effects, depending on whether point antialiasing is enabled. To enable and disable point antialiasing, call glEnable and glDisable with argument GL_POINT_SMOOTH . Point antialiasing is initially disabled.
If point antialiasing is disabled, the actual size is determined by rounding the supplied size to the nearest integer. (If the rounding results in the value 0, it is as if the point size were 1.) If the rounded size is odd, then the center point ( x , y ) of the pixel fragment that represents the point is computed as .sp .ce ( \(lf ~ x sub w ~ \(rf ~+~ .5 , \(lf ~ y sub w ~ \(rf ~+~ .5 ) .sp where w subscripts indicate window coordinates. All pixels that lie within the square grid of the rounded size centered at ( x , y ) make up the fragment. If the size is even, the center point is .sp .ce ( \(lf ~ x sub w ~+~ .5 ~ \(rf, \(lf ~ y sub w ~+~ .5 ~ \(rf ) .sp and the rasterized fragment's centers are the half-integer window coordinates within the square of the rounded size centered at ( x , y ). All pixel fragments produced in rasterizing a nonantialiased point are assigned the same associated data, that of the vertex corresponding to the point.
If antialiasing is enabled, then point rasterization produces a fragment for each pixel square that intersects the region lying within the circle having diameter equal to the current point size and centered at the point's ( x sub w , y sub w ). The coverage value for each fragment is the window coordinate area of the intersection of the circular region with the corresponding pixel square. This value is saved and used in the final rasterization step. The data associated with each fragment is the data associated with the point being rasterized.
Not all sizes are supported when point antialiasing is enabled. If an unsupported size is requested, the nearest supported size is used. Only size 1 is guaranteed to be supported; others depend on the implementation. To query the range of supported sizes and the size difference between supported sizes within the range, call glGet with arguments GL_POINT_SIZE_RANGE and GL_POINT_SIZE_GRANULARITY .
Specifies the diameter of rasterized points. The initial value is 1.
GL_INVALID_VALUE is generated if size is less than or equal to 0.
GL_INVALID_OPERATION is generated if glPointSize is executed between the execution of glBegin and the corresponding execution of glEnd .
void glPolygonMode(int face, int mode)
glPolygonMode controls the interpretation of polygons for rasterization. face describes which polygons mode applies to: front-facing polygons (GL_FRONT ), back-facing polygons (GL_BACK ), or both (GL_FRONT_AND_BACK ). The polygon mode affects only the final rasterization of polygons. In particular, a polygon's vertices are lit and the polygon is clipped and possibly culled before these modes are applied.
Three modes are defined and can be specified in mode:
|
Specifies the polygons that mode applies to. Must be GL_FRONT for front-facing polygons, GL_BACK for back-facing polygons, or GL_FRONT_AND_BACK for front- and back-facing polygons.
Specifies how polygons will be rasterized. Accepted values are GL_POINT , GL_LINE , and GL_FILL . The initial value is GL_FILL for both front- and back-facing polygons.
GL_INVALID_ENUM is generated if either face or mode is not an accepted value.
GL_INVALID_OPERATION is generated if glPolygonMode is executed between the execution of glBegin and the corresponding execution of glEnd .
void glPolygonOffset(float factor, float units)
When GL_POLYGON_OFFSET is enabled, each fragment's depth value will be offset after it is interpolated from the depth values of the appropriate vertices. The value of the offset is "factor" ~*~ DZ ~~+~~ r ~*~ "units", where DZ~ is a measurement of the change in depth relative to the screen area of the polygon, and r is the smallest value that is guaranteed to produce a resolvable offset for a given implementation. The offset is added before the depth test is performed and before the value is written into the depth buffer.
glPolygonOffset is useful for rendering hidden-line images, for applying decals to surfaces, and for rendering solids with highlighted edges.
Specifies a scale factor that is used to create a variable depth offset for each polygon. The initial value is 0.
Is multiplied by an implementation-specific value to create a constant depth offset. The initial value is 0.
GL_INVALID_OPERATION is generated if glPolygonOffset is executed between the execution of glBegin and the corresponding execution of glEnd .
void glPushAttrib(int mask)
glPushAttrib takes one argument, a mask that indicates which groups of state variables to save on the attribute stack. Symbolic constants are used to set bits in the mask. mask is typically constructed by ORing several of these constants together. The special mask GL_ALL_ATTRIB_BITS can be used to save all stackable states.
The symbolic mask constants and their associated GL state are as follows (the second column lists which attributes are saved):
.TS ; l l . GL_ACCUM_BUFFER_BIT Accumulation buffer clear value
GL_COLOR_BUFFER_BIT GL_ALPHA_TEST enable bit Alpha test function and reference value GL_BLEND enable bit Blending source and destination functions Constant blend color Blending equation GL_DITHER enable bit GL_DRAW_BUFFER setting GL_COLOR_LOGIC_OP enable bit GL_INDEX_LOGIC_OP enable bit Logic op function Color mode and index mode clear values Color mode and index mode writemasks
GL_CURRENT_BIT Current RGBA color Current color index Current normal vector Current texture coordinates Current raster position GL_CURRENT_RASTER_POSITION_VALID flag RGBA color associated with current raster position Color index associated with current raster position Texture coordinates associated with current raster position GL_EDGE_FLAG flag
GL_DEPTH_BUFFER_BIT GL_DEPTH_TEST enable bit Depth buffer test function Depth buffer clear value GL_DEPTH_WRITEMASK enable bit
GL_ENABLE_BIT GL_ALPHA_TEST flag GL_AUTO_NORMAL flag GL_BLEND flag Enable bits for the user-definable clipping planes GL_COLOR_MATERIAL GL_CULL_FACE flag GL_DEPTH_TEST flag GL_DITHER flag GL_FOG flag GL_LIGHT i where 0\ <= i<GL_MAX_LIGHTS GL_LIGHTING flag GL_LINE_SMOOTH flag GL_LINE_STIPPLE flag GL_COLOR_LOGIC_OP flag GL_INDEX_LOGIC_OP flag GL_MAP1_ x where x is a map type GL_MAP2_ x where x is a map type GL_NORMALIZE flag GL_POINT_SMOOTH flag GL_POLYGON_OFFSET_LINE flag GL_POLYGON_OFFSET_FILL flag GL_POLYGON_OFFSET_POINT flag GL_POLYGON_SMOOTH flag GL_POLYGON_STIPPLE flag GL_SCISSOR_TEST flag GL_STENCIL_TEST flag GL_TEXTURE_1D flag GL_TEXTURE_2D flag Flags GL_TEXTURE_GEN_ x where x is S, T, R, or Q
GL_EVAL_BIT GL_MAP1_ x enable bits, where x is a map type GL_MAP2_ x enable bits, where x is a map type 1D grid endpoints and divisions 2D grid endpoints and divisions GL_AUTO_NORMAL enable bit
GL_FOG_BIT GL_FOG enable bit Fog color Fog density Linear fog start Linear fog end Fog index GL_FOG_MODE value
GL_HINT_BIT GL_PERSPECTIVE_CORRECTION_HINT setting GL_POINT_SMOOTH_HINT setting GL_LINE_SMOOTH_HINT setting GL_POLYGON_SMOOTH_HINT setting GL_FOG_HINT setting
GL_LIGHTING_BIT GL_COLOR_MATERIAL enable bit GL_COLOR_MATERIAL_FACE value Color material parameters that are tracking the current color Ambient scene color GL_LIGHT_MODEL_LOCAL_VIEWER value GL_LIGHT_MODEL_TWO_SIDE setting GL_LIGHTING enable bit Enable bit for each light Ambient, diffuse, and specular intensity for each light Direction, position, exponent, and cutoff angle for each light Constant, linear, and quadratic attenuation factors for each light Ambient, diffuse, specular, and emissive color for each material Ambient, diffuse, and specular color indices for each material Specular exponent for each material GL_SHADE_MODEL setting
GL_LINE_BIT GL_LINE_SMOOTH flag GL_LINE_STIPPLE enable bit Line stipple pattern and repeat counter Line width
GL_LIST_BIT GL_LIST_BASE setting
GL_PIXEL_MODE_BIT GL_RED_BIAS and GL_RED_SCALE settings GL_GREEN_BIAS and GL_GREEN_SCALE values GL_BLUE_BIAS and GL_BLUE_SCALE GL_ALPHA_BIAS and GL_ALPHA_SCALE GL_DEPTH_BIAS and GL_DEPTH_SCALE GL_INDEX_OFFSET and GL_INDEX_SHIFT values GL_MAP_COLOR and GL_MAP_STENCIL flags GL_ZOOM_X and GL_ZOOM_Y factors GL_READ_BUFFER setting
GL_POINT_BIT GL_POINT_SMOOTH flag Point size
GL_POLYGON_BIT GL_CULL_FACE enable bit GL_CULL_FACE_MODE value GL_FRONT_FACE indicator GL_POLYGON_MODE setting GL_POLYGON_SMOOTH flag GL_POLYGON_STIPPLE enable bit GL_POLYGON_OFFSET_FILL flag GL_POLYGON_OFFSET_LINE flag GL_POLYGON_OFFSET_POINT flag GL_POLYGON_OFFSET_FACTOR GL_POLYGON_OFFSET_UNITS
GL_POLYGON_STIPPLE_BIT Polygon stipple image
GL_SCISSOR_BIT GL_SCISSOR_TEST flag Scissor box
GL_STENCIL_BUFFER_BIT GL_STENCIL_TEST enable bit Stencil function and reference value Stencil value mask Stencil fail, pass, and depth buffer pass actions Stencil buffer clear value Stencil buffer writemask
GL_TEXTURE_BIT Enable bits for the four texture coordinates Border color for each texture image Minification function for each texture image Magnification function for each texture image Texture coordinates and wrap mode for each texture image Color and mode for each texture environment Enable bits GL_TEXTURE_GEN_ x, x is S, T, R, and Q GL_TEXTURE_GEN_MODE setting for S, T, R, and Q glTexGen plane equations for S, T, R, and Q Current texture bindings (for example, GL_TEXTURE_2D_BINDING )
GL_TRANSFORM_BIT Coefficients of the six clipping planes Enable bits for the user-definable clipping planes GL_MATRIX_MODE value GL_NORMALIZE flag
GL_VIEWPORT_BIT Depth range (near and far) Viewport origin and extent .TE
glPopAttrib restores the values of the state variables saved with the last
glPushAttrib command. Those not saved are left unchanged.
It is an error to push attributes onto a full stack, or to pop attributes off an empty stack. In either case, the error flag is set and no other change is made to GL state.
Initially, the attribute stack is empty.
Specifies a mask that indicates which attributes to save. Values for mask are listed below.
GL_STACK_OVERFLOW is generated if glPushAttrib is called while the attribute stack is full.
GL_STACK_UNDERFLOW is generated if glPopAttrib is called while the attribute stack is empty.
GL_INVALID_OPERATION is generated if glPushAttrib or glPopAttrib is executed between the execution of glBegin and the corresponding execution of glEnd .
void glPushClientAttrib(int mask)
glPushClientAttrib takes one argument, a mask that indicates which groups of client-state variables to save on the client attribute stack. Symbolic constants are used to set bits in the mask. mask is typically constructed by OR'ing several of these constants together. The special mask GL_CLIENT_ALL_ATTRIB_BITS can be used to save all stackable client state.
The symbolic mask constants and their associated GL client state are as follows (the second column lists which attributes are saved):
GL_CLIENT_PIXEL_STORE_BIT Pixel storage modes
GL_CLIENT_VERTEX_ARRAY_BIT Vertex arrays (and enables)
glPopClientAttrib restores the values of the client-state variables saved with the last glPushClientAttrib . Those not saved are left unchanged.
It is an error to push attributes onto a full client attribute stack, or to pop attributes off an empty stack. In either case, the error flag is set, and no other change is made to GL state.
Initially, the client attribute stack is empty.
Specifies a mask that indicates which attributes to save. Values for mask are listed below.
GL_STACK_OVERFLOW is generated if glPushClientAttrib is called while the attribute stack is full.
GL_STACK_UNDERFLOW is generated if glPopClientAttrib is called while the attribute stack is empty.
void glPushName(int name)
The name stack is used during selection mode to allow sets of rendering commands to be uniquely identified. It consists of an ordered set of unsigned integers and is initially empty.
glPushName causes name to be pushed onto the name stack. glPopName pops one name off the top of the stack.
The maximum name stack depth is implementation-dependent; call GL_MAX_NAME_STACK_DEPTH to find out the value for a particular implementation. It is an error to push a name onto a full stack, or to pop a name off an empty stack. It is also an error to manipulate the name stack between the execution of glBegin and the corresponding execution of glEnd . In any of these cases, the error flag is set and no other change is made to GL state.
The name stack is always empty while the render mode is not GL_SELECT . Calls to glPushName or glPopName while the render mode is not GL_SELECT are ignored.
Specifies a name that will be pushed onto the name stack.
GL_STACK_OVERFLOW is generated if glPushName is called while the name stack is full.
GL_STACK_UNDERFLOW is generated if glPopName is called while the name stack is empty.
GL_INVALID_OPERATION is generated if glPushName or glPopName is executed between a call to glBegin and the corresponding call to glEnd .
void glRasterPos(float|int x, float|int y, float|int|void z, float|int|void w)
void glRasterPos(array(float|int) pos)
The GL maintains a 3D position in window coordinates. This position, called the raster position, is used to position pixel and bitmap write operations. It is maintained with subpixel accuracy. See glBitmap , glDrawPixels , and glCopyPixels .
The current raster position consists of three window coordinates (x, y, z), a clip coordinate value (w), an eye coordinate distance, a valid bit, and associated color data and texture coordinates. The w coordinate is a clip coordinate, because w is not projected to window coordinates. The variable z defaults to 0 and w defaults to 1.
The object coordinates presented by glRasterPos are treated just like those of a glVertex command: They are transformed by the current modelview and projection matrices and passed to the clipping stage. If the vertex is not culled, then it is projected and scaled to window coordinates, which become the new current raster position, and the GL_CURRENT_RASTER_POSITION_VALID flag is set. If the vertex .I is culled, then the valid bit is cleared and the current raster position and associated color and texture coordinates are undefined.
The current raster position also includes some associated color data and texture coordinates. If lighting is enabled, then GL_CURRENT_RASTER_COLOR (in RGBA mode) or GL_CURRENT_RASTER_INDEX (in color index mode) is set to the color produced by the lighting calculation (see glLight , glLightModel , and
glShadeModel ). If lighting is disabled, current color (in RGBA mode, state variable GL_CURRENT_COLOR ) or color index (in color index mode, state variable GL_CURRENT_INDEX ) is used to update the current raster color.
Likewise, GL_CURRENT_RASTER_TEXTURE_COORDS is updated as a function of GL_CURRENT_TEXTURE_COORDS , based on the texture matrix and the texture generation functions (see glTexGen ). Finally, the distance from the origin of the eye coordinate system to the vertex as transformed by only the modelview matrix replaces GL_CURRENT_RASTER_DISTANCE .
Initially, the current raster position is (0, 0, 0, 1), the current raster distance is 0, the valid bit is set, the associated RGBA color is (1, 1, 1, 1), the associated color index is 1, and the associated texture coordinates are (0, 0, 0, 1). In RGBA mode, GL_CURRENT_RASTER_INDEX is always 1; in color index mode, the current raster RGBA color always maintains its initial value.
Specify the x, y, z, and w object coordinates (if present) for the raster position.
Specifies a pointer to an array of two, three, or four elements, specifying x, y, z, and w coordinates, respectively.
GL_INVALID_OPERATION is generated if glRasterPos is executed between the execution of glBegin and the corresponding execution of glEnd .
void glRotate(float|int|array(float|int) angle, float|int|void x, float|int|void y, float|int|void z)
glRotate produces a rotation of angle degrees around the vector ("x", "y", "z"). The current matrix (see glMatrixMode ) is multiplied by a rotation matrix with the product replacing the current matrix, as if glMultMatrix were called with the following matrix as its argument:
.ce .EQ left ( ~ down 20 matrix { ccol { "x" "x" (1 - c)+ c above "y" "x" (1 - c)+ "z" s above "x" "z" (1 - c)-"y" s above ~0 } ccol {"x" "y" (1 - c)-"z" s above "y" "y" (1 - c)+ c above "y" "z" (1 - c)+ "x" s above ~0 } ccol { "x" "z" (1 - c)+ "y" s above "y" "z" (1 - c)- "x" s above "z" "z" (1 - c) + c above ~0 } ccol { ~0 above ~0 above ~0 above ~1} } ~~ right ) .EN
.sp Where c ~=~ cos("angle"), s ~=~ sine("angle"), and ||(~"x", "y", "z"~)|| ~=~ 1 (if not, the GL will normalize this vector). .sp .sp
If the matrix mode is either GL_MODELVIEW or GL_PROJECTION , all objects drawn after glRotate is called are rotated. Use glPushMatrix and glPopMatrix to save and restore the unrotated coordinate system.
Specifies the angle of rotation, in degrees.
Specify the x, y, and z coordinates of a vector, respectively.
GL_INVALID_OPERATION is generated if glRotate is executed between the execution of glBegin and the corresponding execution of glEnd .
void glScale(float|int|array(float|int) x, float|int|void y, float|int|void z)
glScale produces a nonuniform scaling along the x, y, and z axes. The three parameters indicate the desired scale factor along each of the three axes.
The current matrix (see glMatrixMode ) is multiplied by this scale matrix, and the product replaces the current matrix as if glScale were called with the following matrix as its argument:
.ce .EQ left ( ~ down 20 matrix { ccol { ~"x" above ~0 above ~0 above ~0 } ccol { ~0 above ~"y" above ~0 above ~0 } ccol { ~0 above ~0 above ~"z" above ~0 } ccol { ~0 above ~0 above ~0 above ~1} } ~~ right ) .EN .sp If the matrix mode is either GL_MODELVIEW or GL_PROJECTION , all objects drawn after glScale is called are scaled.
Use glPushMatrix and glPopMatrix to save and restore the unscaled coordinate system.
Specify scale factors along the x, y, and z axes, respectively.
GL_INVALID_OPERATION is generated if glScale is executed between the execution of glBegin and the corresponding execution of glEnd .
void glScissor(int x, int y, int width, int height)
glScissor defines a rectangle, called the scissor box, in window coordinates. The first two arguments, x and y, specify the lower left corner of the box. width and height specify the width and height of the box.
To enable and disable the scissor test, call glEnable and glDisable with argument GL_SCISSOR_TEST . The test is initially disabled. While the test is enabled, only pixels that lie within the scissor box can be modified by drawing commands. Window coordinates have integer values at the shared corners of frame buffer pixels. \f7glScissor(0,0,1,1)\fP allows modification of only the lower left pixel in the window, and \f7glScissor(0,0,0,0)\fP doesn't allow modification of any pixels in the window.
When the scissor test is disabled, it is as though the scissor box includes the entire window.
Specify the lower left corner of the scissor box. Initially (0, 0).
Specify the width and height of the scissor box. When a GL context is first attached to a window, width and height are set to the dimensions of that window.
GL_INVALID_VALUE is generated if either width or height is negative.
GL_INVALID_OPERATION is generated if glScissor is executed between the execution of glBegin and the corresponding execution of glEnd .
void glStencilFunc(int func, int ref, int mask)
Stenciling, like depth-buffering, enables and disables drawing on a per-pixel basis. You draw into the stencil planes using GL drawing primitives, then render geometry and images, using the stencil planes to mask out portions of the screen. Stenciling is typically used in multipass rendering algorithms to achieve special effects, such as decals, outlining, and constructive solid geometry rendering.
The stencil test conditionally eliminates a pixel based on the outcome of a comparison between the reference value and the value in the stencil buffer. To enable and disable the test, call glEnable and glDisable with argument GL_STENCIL_TEST . To specify actions based on the outcome of the stencil test, call glStencilOp .
func is a symbolic constant that determines the stencil comparison function. It accepts one of eight values, shown in the following list. ref is an integer reference value that is used in the stencil comparison. It is clamped to the range [0,2 sup n - 1], where n is the number of bitplanes in the stencil buffer. mask is bitwise ANDed with both the reference value and the stored stencil value, with the ANDed values participating in the comparison. .P If stencil represents the value stored in the corresponding stencil buffer location, the following list shows the effect of each comparison function that can be specified by func. Only if the comparison succeeds is the pixel passed through to the next stage in the rasterization process (see glStencilOp ). All tests treat stencil values as unsigned integers in the range [0,2 sup n - 1], where n is the number of bitplanes in the stencil buffer.
The following values are accepted by func:
|
Specifies the test function. Eight tokens are valid: GL_NEVER , GL_LESS , GL_LEQUAL , GL_GREATER , GL_GEQUAL , GL_EQUAL , GL_NOTEQUAL , and GL_ALWAYS . The initial value is GL_ALWAYS .
Specifies the reference value for the stencil test. ref is clamped to the range [0,2 sup n - 1], where n is the number of bitplanes in the stencil buffer. The initial value is 0.
Specifies a mask that is ANDed with both the reference value and the stored stencil value when the test is done. The initial value is all 1's.
GL_INVALID_ENUM is generated if func is not one of the eight accepted values.
GL_INVALID_OPERATION is generated if glStencilFunc is executed between the execution of glBegin and the corresponding execution of glEnd .
void glStencilMask(int mask)
glStencilMask controls the writing of individual bits in the stencil planes. The least significant n bits of mask, where n is the number of bits in the stencil buffer, specify a mask. Where a 1 appears in the mask, it's possible to write to the corresponding bit in the stencil buffer. Where a 0 appears, the corresponding bit is write-protected. Initially, all bits are enabled for writing.
Specifies a bit mask to enable and disable writing of individual bits in the stencil planes. Initially, the mask is all 1's.
GL_INVALID_OPERATION is generated if glStencilMask is executed between the execution of glBegin and the corresponding execution of glEnd .
void glStencilOp(int fail, int zfail, int zpass)
Stenciling, like depth-buffering, enables and disables drawing on a per-pixel basis. You draw into the stencil planes using GL drawing primitives, then render geometry and images, using the stencil planes to mask out portions of the screen. Stenciling is typically used in multipass rendering algorithms to achieve special effects, such as decals, outlining, and constructive solid geometry rendering.
The stencil test conditionally eliminates a pixel based on the outcome of a comparison between the value in the stencil buffer and a reference value. To enable and disable the test, call glEnable and glDisable with argument GL_STENCIL_TEST ; to control it, call glStencilFunc .
glStencilOp takes three arguments that indicate what happens to the stored stencil value while stenciling is enabled. If the stencil test fails, no change is made to the pixel's color or depth buffers, and fail specifies what happens to the stencil buffer contents. The following six actions are possible.
|
Stencil buffer values are treated as unsigned integers. When incremented and decremented, values are clamped to 0 and 2 sup n - 1, where n is the value returned by querying GL_STENCIL_BITS .
The other two arguments to glStencilOp specify stencil buffer actions that depend on whether subsequent depth buffer tests succeed (zpass) or fail (zfail) (see
glDepthFunc ). The actions are specified using the same six symbolic constants as fail. Note that zfail is ignored when there is no depth buffer, or when the depth buffer is not enabled. In these cases, fail and zpass specify stencil action when the stencil test fails and passes, respectively.
Specifies the action to take when the stencil test fails. Six symbolic constants are accepted: GL_KEEP , GL_ZERO , GL_REPLACE , GL_INCR , GL_DECR , and GL_INVERT . The initial value is GL_KEEP .
Specifies the stencil action when the stencil test passes, but the depth test fails. zfail accepts the same symbolic constants as fail. The initial value is GL_KEEP .
Specifies the stencil action when both the stencil test and the depth test pass, or when the stencil test passes and either there is no depth buffer or depth testing is not enabled. zpass accepts the same symbolic constants as fail. The initial value is GL_KEEP .
GL_INVALID_ENUM is generated if fail, zfail, or zpass is any value other than the six defined constant values.
GL_INVALID_OPERATION is generated if glStencilOp is executed between the execution of glBegin and the corresponding execution of glEnd .
void glTexCoord(float|int|array(float|int) s, float|int|void t, float|int|void r, float|int|void q)
glTexCoord specifies texture coordinates in one, two, three, or four dimensions. glTexCoord1 sets the current texture coordinates to (s, 0, 0, 1); a call to
glTexCoord2 sets them to (s, t, 0, 1). Similarly, glTexCoord3 specifies the texture coordinates as (s, t, r, 1), and glTexCoord4 defines all four components explicitly as (s, t, r, q).
The current texture coordinates are part of the data that is associated with each vertex and with the current raster position. Initially, the values for s, t, r, and q are (0, 0, 0, 1).
Specify s, t, r, and q texture coordinates. Not all parameters are present in all forms of the command.
Specifies a pointer to an array of one, two, three, or four elements, which in turn specify the s, t, r, and q texture coordinates.
void glTexEnv(int target, int pname, float|int|array(float|int) param)
A texture environment specifies how texture values are interpreted when a fragment is textured. target must be GL_TEXTURE_ENV . pname can be either GL_TEXTURE_ENV_MODE or GL_TEXTURE_ENV_COLOR .
If pname is GL_TEXTURE_ENV_MODE , then params is (or points to) the symbolic name of a texture function. Four texture functions may be specified: GL_MODULATE , GL_DECAL , GL_BLEND , and GL_REPLACE .
A texture function acts on the fragment to be textured using the texture image value that applies to the fragment (see glTexParameter ) and produces an RGBA color for that fragment. The following table shows how the RGBA color is produced for each of the three texture functions that can be chosen. C is a triple of color values (RGB) and A is the associated alpha value. RGBA values extracted from a texture image are in the range [0,1]. The subscript f refers to the incoming fragment, the subscript t to the texture image, the subscript c to the texture environment color, and subscript v indicates a value produced by the texture function.
A texture image can have up to four components per texture element (see glTexImage1D , glTexImage2D , glCopyTexImage1D , and glCopyTexImage2D ). In a one-component image, L sub t indicates that single component. A two-component image uses L sub t and A sub t. A three-component image has only a color value, C sub t. A four-component image has both a color value C sub t and an alpha value A sub t.
.ne .TS center box tab(:) ; ci || ci s s s ci || c c c c c || c | c | c | c. Base internal:Texture functions format:GL_MODULATE :GL_DECAL :GL_BLEND :GL_REPLACE = GL_ALPHA :C sub v = C sub f:undefined:C sub v = C sub f:C sub v = C sub f \^ :A sub v = A sub f A sub t:\^:A sub v = A sub f:A sub v = A sub t _ GL_LUMINANCE :C sub v = L sub t C sub f:undefined:C sub v = ( 1 - L sub t ) C sub f:C sub v = L sub t 1: : :+ L sub t C sub c: : : : : : A sub v = A sub f:\^: A sub v = A sub f:A sub v = A sub f _ GL_LUMINANCE :C sub v = L sub t C sub f:undefined:C sub v = ( 1 - L sub t ) C sub f :C sub v = L sub t \_ALPHA : : : + L sub t C sub c 2: : : : :A sub v = A sub t A sub f:\^:A sub v = A sub t A sub f:A sub v = A sub t _ GL_INTENSITY :C sub v = C sub f I sub t:undefined:C sub v = ( 1 - I sub t ) C sub f :C sub v = I sub t : : :+ I sub t C sub c : : : : \^ :A sub v = A sub f I sub t:\^:A sub v = ( 1 - I sub t ) A sub f :A sub v = I sub t : : :+ I sub t A sub c: _ GL_RGB :C sub v = C sub t C sub f:C sub v = C sub t:C sub v = (1 - C sub t) C sub f :C sub v = C sub t 3: : : + C sub t C sub c : : : : :A sub v = A sub f:A sub v = A sub f:A sub v = A sub f:A sub v = A sub f _ GL_RGBA :C sub v = C sub t C sub f:C sub v = ( 1 - A sub t ) C sub f :C sub v = (1 - C sub t) C sub f :C sub v = C sub t 4: :+ A sub t C sub t: + C sub t C sub c : : : : :A sub v = A sub t A sub f:A sub v = A sub f:A sub v = A sub t A sub f:A sub v = A sub t .TE .sp If pname is GL_TEXTURE_ENV_COLOR , params is a pointer to an array that holds an RGBA color consisting of four values. Integer color components are interpreted linearly such that the most positive integer maps to 1.0, and the most negative integer maps to -1.0. The values are clamped to the range [0,1] when they are specified. C sub c takes these four values.
GL_TEXTURE_ENV_MODE defaults to GL_MODULATE and GL_TEXTURE_ENV_COLOR defaults to (0, 0, 0, 0).
Specifies a texture environment. Must be GL_TEXTURE_ENV .
Specifies the symbolic name of a single-valued texture environment parameter. Must be GL_TEXTURE_ENV_MODE .
Specifies a single symbolic constant, one of GL_MODULATE , GL_DECAL , GL_BLEND , or GL_REPLACE .
Specifies a texture environment. Must be GL_TEXTURE_ENV .
Specifies the symbolic name of a texture environment parameter. Accepted values are GL_TEXTURE_ENV_MODE and GL_TEXTURE_ENV_COLOR .
Specifies a pointer to a parameter array that contains either a single symbolic constant or an RGBA color.
GL_INVALID_ENUM is generated when target or pname is not one of the accepted defined values, or when params should have a defined constant value (based on the value of pname) and does not.
GL_INVALID_OPERATION is generated if glTexEnv is executed between the execution of glBegin and the corresponding execution of glEnd .
void glTexGen(int coord, int pname, float|int|array(float|int) param)
glTexGen selects a texture-coordinate generation function or supplies coefficients for one of the functions. coord names one of the (s, t, r, q) texture coordinates; it must be one of the symbols GL_S , GL_T , GL_R , or GL_Q . pname must be one of three symbolic constants: GL_TEXTURE_GEN_MODE , GL_OBJECT_PLANE , or GL_EYE_PLANE . If pname is GL_TEXTURE_GEN_MODE , then params chooses a mode, one of GL_OBJECT_LINEAR , GL_EYE_LINEAR , or GL_SPHERE_MAP . If pname is either GL_OBJECT_PLANE or GL_EYE_PLANE , params contains coefficients for the corresponding texture generation function. .P If the texture generation function is GL_OBJECT_LINEAR , the function
.ce g = p sub 1 x sub o + p sub 2 y sub o + p sub 3 z sub o + p sub 4 w sub o
is used, where g is the value computed for the coordinate named in coord, p sub 1, p sub 2, p sub 3, and p sub 4 are the four values supplied in params, and x sub o, y sub o, z sub o, and w sub o are the object coordinates of the vertex. This function can be used, for example, to texture-map terrain using sea level as a reference plane (defined by p sub 1, p sub 2, p sub 3, and p sub 4). The altitude of a terrain vertex is computed by the GL_OBJECT_LINEAR coordinate generation function as its distance from sea level; that altitude can then be used to index the texture image to map white snow onto peaks and green grass onto foothills.
If the texture generation function is GL_EYE_LINEAR , the function
.ce g = {p sub 1} sup prime ~x sub e + {p sub 2} sup prime ~y sub e + {p sub 3} sup prime ~z sub e + {p sub 4} sup prime ~w sub e
is used, where
.ce $( {p sub 1} sup prime ~~{p sub 2} sup prime~~{p sub 3} sup prime~~ {{p sub 4}sup prime}) = ( p sub 1~~ p sub 2~~ p sub 3~~ p sub 4 ) ~M sup -1$
and x sub e, y sub e, z sub e, and w sub e are the eye coordinates of the vertex, p sub 1, p sub 2, p sub 3, and p sub 4 are the values supplied in params, and M is the modelview matrix when glTexGen is invoked. If M is poorly conditioned or singular, texture coordinates generated by the resulting function may be inaccurate or undefined.
Note that the values in params define a reference plane in eye coordinates. The modelview matrix that is applied to them may not be the same one in effect when the polygon vertices are transformed. This function establishes a field of texture coordinates that can produce dynamic contour lines on moving objects.
If pname is GL_SPHERE_MAP and coord is either GL_S or GL_T , s and t texture coordinates are generated as follows. Let u be the unit vector pointing from the origin to the polygon vertex (in eye coordinates). Let n sup prime be the current normal, after transformation to eye coordinates. Let
.ce f ~=~ ( f sub x~~f sub y~~f sub z ) sup T be the reflection vector such that
.ce f ~=~ u ~-~ 2 n sup prime n sup prime sup T u
Finally, let m ~=~ 2 sqrt { f sub x sup {~2} + f sub y sup {~2} + (f sub z + 1 ) sup 2}. Then the values assigned to the s and t texture coordinates are
.ce 1 s ~=~ f sub x over m ~+~ 1 over 2 .sp .ce 1 t ~=~ f sub y over m ~+~ 1 over 2
To enable or disable a texture-coordinate generation function, call glEnable or glDisable with one of the symbolic texture-coordinate names (GL_TEXTURE_GEN_S , GL_TEXTURE_GEN_T , GL_TEXTURE_GEN_R , or GL_TEXTURE_GEN_Q ) as the argument. When enabled, the specified texture coordinate is computed according to the generating function associated with that coordinate. When disabled, subsequent vertices take the specified texture coordinate from the current set of texture coordinates. Initially, all texture generation functions are set to GL_EYE_LINEAR and are disabled. Both s plane equations are (1, 0, 0, 0), both t plane equations are (0, 1, 0, 0), and all r and q plane equations are (0, 0, 0, 0).
Specifies a texture coordinate. Must be one of GL_S , GL_T , GL_R , or GL_Q .
Specifies the symbolic name of the texture-coordinate generation function. Must be GL_TEXTURE_GEN_MODE .
Specifies a single-valued texture generation parameter, one of GL_OBJECT_LINEAR , GL_EYE_LINEAR , or GL_SPHERE_MAP .
Specifies a texture coordinate. Must be one of GL_S , GL_T , GL_R , or GL_Q .
Specifies the symbolic name of the texture-coordinate generation function or function parameters. Must be GL_TEXTURE_GEN_MODE , GL_OBJECT_PLANE , or GL_EYE_PLANE .
Specifies a pointer to an array of texture generation parameters. If pname is GL_TEXTURE_GEN_MODE , then the array must contain a single symbolic constant, one of GL_OBJECT_LINEAR , GL_EYE_LINEAR , or GL_SPHERE_MAP . Otherwise, params holds the coefficients for the texture-coordinate generation function specified by pname.
GL_INVALID_ENUM is generated when coord or pname is not an accepted defined value, or when pname is GL_TEXTURE_GEN_MODE and params is not an accepted defined value.
GL_INVALID_ENUM is generated when pname is GL_TEXTURE_GEN_MODE , params is GL_SPHERE_MAP , and coord is either GL_R or GL_Q .
GL_INVALID_OPERATION is generated if glTexGen is executed between the execution of glBegin and the corresponding execution of glEnd .
void glTexImage2D(int target, int level, int internalformat, object|mapping(string:object) width, object|mapping(string:object) height, int border, object|mapping(string:object) format, object|mapping(string:object) type, array(object|mapping(string:object)) pixels)
Texturing maps a portion of a specified texture image onto each graphical primitive for which texturing is enabled. To enable and disable two-dimensional texturing, call glEnable and glDisable with argument GL_TEXTURE_2D .
To define texture images, call glTexImage2D . The arguments describe the parameters of the texture image, such as height, width, width of the border, level-of-detail number (see glTexParameter ), and number of color components provided. The last three arguments describe how the image is represented in memory; they are identical to the pixel formats used for glDrawPixels .
If target is GL_PROXY_TEXTURE_2D , no data is read from pixels, but all of the texture image state is recalculated, checked for consistency, and checked against the implementation's capabilities. If the implementation cannot handle a texture of the requested texture size, it sets all of the image state to 0, but does not generate an error (see glGetError ). To query for an entire mipmap array, use an image array level greater than or equal to 1. .P If target is GL_TEXTURE_2D , data is read from pixels as a sequence of signed or unsigned bytes, shorts, or longs, or single-precision floating-point values, depending on type. These values are grouped into sets of one, two, three, or four values, depending on format, to form elements. If type is GL_BITMAP , the data is considered as a string of unsigned bytes (and format must be GL_COLOR_INDEX ). Each data byte is treated as eight 1-bit elements, with bit ordering determined by GL_UNPACK_LSB_FIRST (see glPixelStore ).
The first element corresponds to the lower left corner of the texture image. Subsequent elements progress left-to-right through the remaining texels in the lowest row of the texture image, and then in successively higher rows of the texture image. The final element corresponds to the upper right corner of the texture image.
format determines the composition of each element in pixels. It can assume one of nine symbolic values:
|
Refer to the glDrawPixels reference page for a description of the acceptable values for the type parameter.
If an application wants to store the texture at a certain resolution or in a certain format, it can request the resolution and format with internalformat. The GL will choose an internal representation that closely approximates that requested by internalformat, but it may not match exactly. (The representations specified by GL_LUMINANCE , GL_LUMINANCE_ALPHA , GL_RGB , and GL_RGBA must match exactly. The numeric values 1, 2, 3, and 4 may also be used to specify the above representations.)
Use the GL_PROXY_TEXTURE_2D target to try out a resolution and format. The implementation will update and recompute its best match for the requested storage resolution and format. To then query this state, call glGetTexLevelParameter . If the texture cannot be accommodated, texture state is set to 0.
A one-component texture image uses only the red component of the RGBA color extracted from pixels. A two-component image uses the R and A values. A three-component image uses the R, G, and B values. A four-component image uses all of the RGBA components.
Specifies the target texture. Must be GL_TEXTURE_2D or GL_PROXY_TEXTURE_2D .
Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image.
Specifies the number of color components in the texture. Must be 1, 2, 3, or 4, or one of the following symbolic constants: GL_ALPHA , GL_ALPHA4 , GL_ALPHA8 , GL_ALPHA12 , GL_ALPHA16 , GL_LUMINANCE , GL_LUMINANCE4 , GL_LUMINANCE8 , GL_LUMINANCE12 , GL_LUMINANCE16 , GL_LUMINANCE_ALPHA , GL_LUMINANCE4_ALPHA4 , GL_LUMINANCE6_ALPHA2 , GL_LUMINANCE8_ALPHA8 , GL_LUMINANCE12_ALPHA4 , GL_LUMINANCE12_ALPHA12 , GL_LUMINANCE16_ALPHA16 , GL_INTENSITY , GL_INTENSITY4 , GL_INTENSITY8 , GL_INTENSITY12 , GL_INTENSITY16 , GL_R3_G3_B2 , GL_RGB , GL_RGB4 , GL_RGB5 , GL_RGB8 , GL_RGB10 , GL_RGB12 , GL_RGB16 , GL_RGBA , GL_RGBA2 , GL_RGBA4 , GL_RGB5_A1 , GL_RGBA8 , GL_RGB10_A2 , GL_RGBA12 , or GL_RGBA16 .
Specifies the width of the texture image. Must be 2 sup n + 2 ( "border" ) for some integer n. All implementations support texture images that are at least 64 texels wide.
Specifies the height of the texture image. Must be 2 sup m + 2 ( "border" ) for some integer m. All implementations support texture images that are at least 64 texels high.
Specifies the width of the border. Must be either 0 or 1.
Specifies the format of the pixel data. The following symbolic values are accepted: GL_COLOR_INDEX , GL_RED , GL_GREEN , GL_BLUE , GL_ALPHA , GL_RGB , GL_RGBA , GL_LUMINANCE , and GL_LUMINANCE_ALPHA .
Specifies the data type of the pixel data. The following symbolic values are accepted: GL_UNSIGNED_BYTE , GL_BYTE , GL_BITMAP , GL_UNSIGNED_SHORT , GL_SHORT , GL_UNSIGNED_INT , GL_INT , and GL_FLOAT .
Specifies a pointer to the image data in memory.
GL_INVALID_ENUM is generated if target is not GL_TEXTURE_2D or GL_PROXY_TEXTURE_2D .
GL_INVALID_ENUM is generated if format is not an accepted format constant. Format constants other than GL_STENCIL_INDEX and GL_DEPTH_COMPONENT are accepted.
GL_INVALID_ENUM is generated if type is not a type constant.
GL_INVALID_ENUM is generated if type is GL_BITMAP and format is not GL_COLOR_INDEX .
GL_INVALID_VALUE is generated if level is less than 0. .P .P GL_INVALID_VALUE may be generated if level is greater than $log sub 2$max, where max is the returned value of GL_MAX_TEXTURE_SIZE .
GL_INVALID_VALUE is generated if internalformat is not 1, 2, 3, 4, or one of the accepted resolution and format symbolic constants.
GL_INVALID_VALUE is generated if width or height is less than 0 or greater than 2 + GL_MAX_TEXTURE_SIZE , or if either cannot be represented as 2 sup k + 2("border") for some integer value of k.
GL_INVALID_VALUE is generated if border is not 0 or 1.
GL_INVALID_OPERATION is generated if glTexImage2D is executed between the execution of glBegin and the corresponding execution of glEnd .
void glTexParameter(int target, int pname, float|int|array(float|int) param)
Texture mapping is a technique that applies an image onto an object's surface as if the image were a decal or cellophane shrink-wrap. The image is created in texture space, with an (s, t) coordinate system. A texture is a one- or two-dimensional image and a set of parameters that determine how samples are derived from the image.
glTexParameter assigns the value or values in params to the texture parameter specified as pname. target defines the target texture, either GL_TEXTURE_1D or GL_TEXTURE_2D . The following symbols are accepted in pname:
|
.RE
|
|
Specifies the target texture, which must be either GL_TEXTURE_1D or GL_TEXTURE_2D .
Specifies the symbolic name of a single-valued texture parameter. pname can be one of the following: GL_TEXTURE_MIN_FILTER , GL_TEXTURE_MAG_FILTER , GL_TEXTURE_WRAP_S , GL_TEXTURE_WRAP_T , or GL_TEXTURE_PRIORITY .
Specifies the value of pname.
Specifies the target texture, which must be either GL_TEXTURE_1D or GL_TEXTURE_2D .
Specifies the symbolic name of a texture parameter. pname can be one of the following: GL_TEXTURE_MIN_FILTER , GL_TEXTURE_MAG_FILTER , GL_TEXTURE_WRAP_S , GL_TEXTURE_WRAP_T , GL_TEXTURE_BORDER_COLOR , or GL_TEXTURE_PRIORITY .
Specifies a pointer to an array where the value or values of pname are stored.
GL_INVALID_ENUM is generated if target or pname is not one of the accepted defined values.
GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not.
GL_INVALID_OPERATION is generated if glTexParameter is executed between the execution of glBegin and the corresponding execution of glEnd .
void glTexSubImage2D(int target, int level, int xoffset, int yoffset, object|mapping(string:object) width, object|mapping(string:object) height, object|mapping(string:object) format, object|mapping(string:object) type, array(object|mapping(string:object)) pixels)
Texturing maps a portion of a specified texture image onto each graphical primitive for which texturing is enabled. To enable and disable two-dimensional texturing, call glEnable and glDisable with argument GL_TEXTURE_2D .
glTexSubImage2D redefines a contiguous subregion of an existing two-dimensional texture image. The texels referenced by pixels replace the portion of the existing texture array with x indices xoffset and "xoffset"~+~"width"~-~1, inclusive, and y indices yoffset and "yoffset"~+~"height"~-~1, inclusive. This region may not include any texels outside the range of the texture array as it was originally specified. It is not an error to specify a subtexture with zero width or height, but such a specification has no effect.
Specifies the target texture. Must be GL_TEXTURE_2D .
Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image.
Specifies a texel offset in the x direction within the texture array.
Specifies a texel offset in the y direction within the texture array.
Specifies the width of the texture subimage.
Specifies the height of the texture subimage.
Specifies the format of the pixel data. The following symbolic values are accepted: GL_COLOR_INDEX , GL_RED , GL_GREEN , GL_BLUE , GL_ALPHA , GL_RGB , GL_RGBA , GL_LUMINANCE , and GL_LUMINANCE_ALPHA .
Specifies the data type of the pixel data. The following symbolic values are accepted: GL_UNSIGNED_BYTE , GL_BYTE , GL_BITMAP , GL_UNSIGNED_SHORT , GL_SHORT , GL_UNSIGNED_INT , GL_INT , and GL_FLOAT .
Specifies a pointer to the image data in memory.
GL_INVALID_ENUM is generated if target is not GL_TEXTURE_2D .
GL_INVALID_OPERATION is generated if the texture array has not been defined by a previous glTexImage2D operation.
GL_INVALID_VALUE is generated if level is less than 0. .P P GL_INVALID_VALUE may be generated if level is greater than log sub 2max, where max is the returned value of GL_MAX_TEXTURE_SIZE .
GL_INVALID_VALUE is generated if "xoffset" ~<~ ~-b, ("xoffset"~+~"width") ~>~ (w~-~b), "yoffset" ~<~ ~-b, or ("yoffset" ~+~ "height") ~>~ (h~-~b). Where w is the GL_TEXTURE_WIDTH , h is the GL_TEXTURE_HEIGHT , and b is the border width of the texture image being modified. Note that w and h include twice the border width.
GL_INVALID_VALUE is generated if width or height is less than 0.
GL_INVALID_ENUM is generated if format is not an accepted format constant.
GL_INVALID_ENUM is generated if type is not a type constant.
GL_INVALID_ENUM is generated if type is GL_BITMAP and format is not GL_COLOR_INDEX .
GL_INVALID_OPERATION is generated if glTexSubImage2D is executed between the execution of glBegin and the corresponding execution of glEnd .
void glTranslate(float|int|array(float|int) x, float|int|void y, float|int|void z)
glTranslate produces a translation by ("x","y","z"). The current matrix (see
glMatrixMode ) is multiplied by this translation matrix, with the product replacing the current matrix, as if glMultMatrix were called with the following matrix for its argument: .sp .ce .EQ left ( ~ down 20 matrix { ccol { 1~~ above 0~~ above 0~~ above 0~~ } ccol { 0~~ above 1~~ above 0~~ above 0~~ } ccol { 0~~ above 0~~ above 1~~ above 0~~ } ccol { "x"~ above "y"~ above "z"~ above 1} } ~~right ) .EN .sp .RE If the matrix mode is either GL_MODELVIEW or GL_PROJECTION , all objects drawn after a call to glTranslate are translated.
Use glPushMatrix and glPopMatrix to save and restore the untranslated coordinate system.
Specify the x, y, and z coordinates of a translation vector.
GL_INVALID_OPERATION is generated if glTranslate is executed between the execution of glBegin and the corresponding execution of glEnd .
void glVertex(float|int|array(float|int) x, float|int|void y, float|int|void z, float|int|void w)
glVertex commands are used within glBegin /glEnd pairs to specify point, line, and polygon vertices. The current color, normal, and texture coordinates are associated with the vertex when glVertex is called.
When only x and y are specified, z defaults to 0 and w defaults to 1. When x, y, and z are specified, w defaults to 1.
Specify x, y, z, and w coordinates of a vertex. Not all parameters are present in all forms of the command.
Specifies a pointer to an array of two, three, or four elements. The elements of a two-element array are x and y; of a three-element array, x, y, and z; and of a four-element array, x, y, z, and w.
void glViewport(int x, int y, int width, int height)
glViewport specifies the affine transformation of x and y from normalized device coordinates to window coordinates. Let (x sub nd, y sub nd) be normalized device coordinates. Then the window coordinates (x sub w, y sub w) are computed as follows: .sp .ce .EQ x sub w ~=~ ( x sub nd + 1 ) left ( "width" over 2 right ) ~+~ "x" .EN .sp .ce .EQ y sub w ~=~ ( y sub nd + 1 ) left ( "height" over 2 right ) ~+~ "y" .EN .RE
Viewport width and height are silently clamped to a range that depends on the implementation. To query this range, call glGet with argument GL_MAX_VIEWPORT_DIMS .
Specify the lower left corner of the viewport rectangle, in pixels. The initial value is (0,0).
Specify the width and height of the viewport. When a GL context is first attached to a window, width and height are set to the dimensions of that window.
GL_INVALID_VALUE is generated if either width or height is negative.
GL_INVALID_OPERATION is generated if glViewport is executed between the execution of glBegin and the corresponding execution of glEnd .
void glEnd()
glBegin and glEnd delimit the vertices that define a primitive or a group of like primitives. glBegin accepts a single argument that specifies in which of ten ways the vertices are interpreted. Taking n as an integer count starting at one, and N as the total number of vertices specified, the interpretations are as follows:
|
Only a subset of GL commands can be used between glBegin and glEnd . The commands are glVertex , glColor , glIndex , glNormal , glTexCoord , glEvalCoord , glEvalPoint , glArrayElement , glMaterial , and glEdgeFlag . Also, it is acceptable to use glCallList or glCallLists to execute display lists that include only the preceding commands. If any other GL command is executed between glBegin and glEnd , the error flag is set and the command is ignored.
Regardless of the value chosen for mode, there is no limit to the number of vertices that can be defined between glBegin and glEnd . Lines, triangles, quadrilaterals, and polygons that are incompletely specified are not drawn. Incomplete specification results when either too few vertices are provided to specify even a single primitive or when an incorrect multiple of vertices is specified. The incomplete primitive is ignored; the rest are drawn.
The minimum specification of vertices for each primitive is as follows: 1 for a point, 2 for a line, 3 for a triangle, 4 for a quadrilateral, and 3 for a polygon. Modes that require a certain multiple of vertices are GL_LINES (2), GL_TRIANGLES (3), GL_QUADS (4), and GL_QUAD_STRIP (2).
Specifies the primitive or primitives that will be created from vertices presented between glBegin and the subsequent glEnd . Ten symbolic constants are accepted: GL_POINTS , GL_LINES , GL_LINE_STRIP , GL_LINE_LOOP , GL_TRIANGLES , GL_TRIANGLE_STRIP , GL_TRIANGLE_FAN , GL_QUADS , GL_QUAD_STRIP , and GL_POLYGON .
GL_INVALID_ENUM is generated if mode is set to an unaccepted value.
GL_INVALID_OPERATION is generated if glBegin is executed between a glBegin and the corresponding execution of glEnd .
GL_INVALID_OPERATION is generated if glEnd is executed without being preceded by a glBegin .
GL_INVALID_OPERATION is generated if a command other than glVertex , glColor , glIndex , glNormal , glTexCoord , glEvalCoord , glEvalPoint , glArrayElement , glMaterial , glEdgeFlag , glCallList , or glCallLists is executed between the execution of glBegin and the corresponding execution glEnd .
Execution of glEnableClientState , glDisableClientState , glEdgeFlagPointer , glTexCoordPointer , glColorPointer , glIndexPointer , glNormalPointer ,
glVertexPointer , glInterleavedArrays , or glPixelStore is not allowed after a call to glBegin and before the corresponding call to glEnd , but an error may or may not be generated.
void glEndList()
Display lists are groups of GL commands that have been stored for subsequent execution. Display lists are created with glNewList . All subsequent commands are placed in the display list, in the order issued, until glEndList is called.
glNewList has two arguments. The first argument, list, is a positive integer that becomes the unique name for the display list. Names can be created and reserved with glGenLists and tested for uniqueness with glIsList . The second argument, mode, is a symbolic constant that can assume one of two values:
|
Certain commands are not compiled into the display list but are executed immediately, regardless of the display-list mode. These commands are glColorPointer , glDeleteLists , glDisableClientState , glEdgeFlagPointer , glEnableClientState , glFeedbackBuffer , glFinish , glFlush , glGenLists , glIndexPointer , glInterleavedArrays , glIsEnabled , glIsList , glNormalPointer , glPopClientAttrib , glPixelStore , glPushClientAttrib , glReadPixels , glRenderMode , glSelectBuffer , glTexCoordPointer , glVertexPointer , and all of the glGet commands.
Similarly, glTexImage2D and glTexImage1D are executed immediately and not compiled into the display list when their first argument is GL_PROXY_TEXTURE_2D or GL_PROXY_TEXTURE_1D , respectively.
When glEndList is encountered, the display-list definition is completed by associating the list with the unique name list (specified in the glNewList command). If a display list with name list already exists, it is replaced only when glEndList is called.
Specifies the display-list name.
Specifies the compilation mode, which can be GL_COMPILE or GL_COMPILE_AND_EXECUTE .
GL_INVALID_VALUE is generated if list is 0.
GL_INVALID_ENUM is generated if mode is not an accepted value.
GL_INVALID_OPERATION is generated if glEndList is called without a preceding glNewList , or if glNewList is called while a display list is being defined.
GL_INVALID_OPERATION is generated if glNewList or glEndList is executed between the execution of glBegin and the corresponding execution of glEnd .
GL_OUT_OF_MEMORY is generated if there is insufficient memory to compile the display list. If the GL version is 1.1 or greater, no change is made to the previous contents of the display list, if any, and no other change is made to the GL state. (It is as if no attempt had been made to create the new display list.)
void glFinish()
glFinish does not return until the effects of all previously called GL commands are complete. Such effects include all changes to GL state, all changes to connection state, and all changes to the frame buffer contents.
GL_INVALID_OPERATION is generated if glFinish is executed between the execution of glBegin and the corresponding execution of glEnd .
void glFlush()
Different GL implementations buffer commands in several different locations, including network buffers and the graphics accelerator itself. glFlush empties all of these buffers, causing all issued commands to be executed as quickly as they are accepted by the actual rendering engine. Though this execution may not be completed in any particular time period, it does complete in finite time.
Because any GL program might be executed over a network, or on an accelerator that buffers commands, all programs should call glFlush whenever they count on having all of their previously issued commands completed. For example, call glFlush before waiting for user input that depends on the generated image.
GL_INVALID_OPERATION is generated if glFlush is executed between the execution of glBegin and the corresponding execution of glEnd .
void glInitNames()
The name stack is used during selection mode to allow sets of rendering commands to be uniquely identified. It consists of an ordered set of unsigned integers. glInitNames causes the name stack to be initialized to its default empty state.
The name stack is always empty while the render mode is not GL_SELECT . Calls to glInitNames while the render mode is not GL_SELECT are ignored.
GL_INVALID_OPERATION is generated if glInitNames is executed between the execution of glBegin and the corresponding execution of glEnd .
void glLoadIdentity()
glLoadIdentity replaces the current matrix with the identity matrix. It is semantically equivalent to calling glLoadMatrix with the identity matrix
.ce
.EQ left ( down 20 { ~ matrix { ccol { 1 above 0 above 0 above 0~ } ccol { 0 above 1 above 0 above 0~ } ccol { 0 above 0 above 1 above 0~ } ccol { 0 above 0 above 0 above 1 } } } ~~ right ) .EN
but in some cases it is more efficient.
GL_INVALID_OPERATION is generated if glLoadIdentity is executed between the execution of glBegin and the corresponding execution of glEnd .
void glPopAttrib()
glPushAttrib takes one argument, a mask that indicates which groups of state variables to save on the attribute stack. Symbolic constants are used to set bits in the mask. mask is typically constructed by ORing several of these constants together. The special mask GL_ALL_ATTRIB_BITS can be used to save all stackable states.
The symbolic mask constants and their associated GL state are as follows (the second column lists which attributes are saved):
.TS ; l l . GL_ACCUM_BUFFER_BIT Accumulation buffer clear value
GL_COLOR_BUFFER_BIT GL_ALPHA_TEST enable bit Alpha test function and reference value GL_BLEND enable bit Blending source and destination functions Constant blend color Blending equation GL_DITHER enable bit GL_DRAW_BUFFER setting GL_COLOR_LOGIC_OP enable bit GL_INDEX_LOGIC_OP enable bit Logic op function Color mode and index mode clear values Color mode and index mode writemasks
GL_CURRENT_BIT Current RGBA color Current color index Current normal vector Current texture coordinates Current raster position GL_CURRENT_RASTER_POSITION_VALID flag RGBA color associated with current raster position Color index associated with current raster position Texture coordinates associated with current raster position GL_EDGE_FLAG flag
GL_DEPTH_BUFFER_BIT GL_DEPTH_TEST enable bit Depth buffer test function Depth buffer clear value GL_DEPTH_WRITEMASK enable bit
GL_ENABLE_BIT GL_ALPHA_TEST flag GL_AUTO_NORMAL flag GL_BLEND flag Enable bits for the user-definable clipping planes GL_COLOR_MATERIAL GL_CULL_FACE flag GL_DEPTH_TEST flag GL_DITHER flag GL_FOG flag GL_LIGHT i where 0\ <= i<GL_MAX_LIGHTS GL_LIGHTING flag GL_LINE_SMOOTH flag GL_LINE_STIPPLE flag GL_COLOR_LOGIC_OP flag GL_INDEX_LOGIC_OP flag GL_MAP1_ x where x is a map type GL_MAP2_ x where x is a map type GL_NORMALIZE flag GL_POINT_SMOOTH flag GL_POLYGON_OFFSET_LINE flag GL_POLYGON_OFFSET_FILL flag GL_POLYGON_OFFSET_POINT flag GL_POLYGON_SMOOTH flag GL_POLYGON_STIPPLE flag GL_SCISSOR_TEST flag GL_STENCIL_TEST flag GL_TEXTURE_1D flag GL_TEXTURE_2D flag Flags GL_TEXTURE_GEN_ x where x is S, T, R, or Q
GL_EVAL_BIT GL_MAP1_ x enable bits, where x is a map type GL_MAP2_ x enable bits, where x is a map type 1D grid endpoints and divisions 2D grid endpoints and divisions GL_AUTO_NORMAL enable bit
GL_FOG_BIT GL_FOG enable bit Fog color Fog density Linear fog start Linear fog end Fog index GL_FOG_MODE value
GL_HINT_BIT GL_PERSPECTIVE_CORRECTION_HINT setting GL_POINT_SMOOTH_HINT setting GL_LINE_SMOOTH_HINT setting GL_POLYGON_SMOOTH_HINT setting GL_FOG_HINT setting
GL_LIGHTING_BIT GL_COLOR_MATERIAL enable bit GL_COLOR_MATERIAL_FACE value Color material parameters that are tracking the current color Ambient scene color GL_LIGHT_MODEL_LOCAL_VIEWER value GL_LIGHT_MODEL_TWO_SIDE setting GL_LIGHTING enable bit Enable bit for each light Ambient, diffuse, and specular intensity for each light Direction, position, exponent, and cutoff angle for each light Constant, linear, and quadratic attenuation factors for each light Ambient, diffuse, specular, and emissive color for each material Ambient, diffuse, and specular color indices for each material Specular exponent for each material GL_SHADE_MODEL setting
GL_LINE_BIT GL_LINE_SMOOTH flag GL_LINE_STIPPLE enable bit Line stipple pattern and repeat counter Line width
GL_LIST_BIT GL_LIST_BASE setting
GL_PIXEL_MODE_BIT GL_RED_BIAS and GL_RED_SCALE settings GL_GREEN_BIAS and GL_GREEN_SCALE values GL_BLUE_BIAS and GL_BLUE_SCALE GL_ALPHA_BIAS and GL_ALPHA_SCALE GL_DEPTH_BIAS and GL_DEPTH_SCALE GL_INDEX_OFFSET and GL_INDEX_SHIFT values GL_MAP_COLOR and GL_MAP_STENCIL flags GL_ZOOM_X and GL_ZOOM_Y factors GL_READ_BUFFER setting
GL_POINT_BIT GL_POINT_SMOOTH flag Point size
GL_POLYGON_BIT GL_CULL_FACE enable bit GL_CULL_FACE_MODE value GL_FRONT_FACE indicator GL_POLYGON_MODE setting GL_POLYGON_SMOOTH flag GL_POLYGON_STIPPLE enable bit GL_POLYGON_OFFSET_FILL flag GL_POLYGON_OFFSET_LINE flag GL_POLYGON_OFFSET_POINT flag GL_POLYGON_OFFSET_FACTOR GL_POLYGON_OFFSET_UNITS
GL_POLYGON_STIPPLE_BIT Polygon stipple image
GL_SCISSOR_BIT GL_SCISSOR_TEST flag Scissor box
GL_STENCIL_BUFFER_BIT GL_STENCIL_TEST enable bit Stencil function and reference value Stencil value mask Stencil fail, pass, and depth buffer pass actions Stencil buffer clear value Stencil buffer writemask
GL_TEXTURE_BIT Enable bits for the four texture coordinates Border color for each texture image Minification function for each texture image Magnification function for each texture image Texture coordinates and wrap mode for each texture image Color and mode for each texture environment Enable bits GL_TEXTURE_GEN_ x, x is S, T, R, and Q GL_TEXTURE_GEN_MODE setting for S, T, R, and Q glTexGen plane equations for S, T, R, and Q Current texture bindings (for example, GL_TEXTURE_2D_BINDING )
GL_TRANSFORM_BIT Coefficients of the six clipping planes Enable bits for the user-definable clipping planes GL_MATRIX_MODE value GL_NORMALIZE flag
GL_VIEWPORT_BIT Depth range (near and far) Viewport origin and extent .TE
glPopAttrib restores the values of the state variables saved with the last
glPushAttrib command. Those not saved are left unchanged.
It is an error to push attributes onto a full stack, or to pop attributes off an empty stack. In either case, the error flag is set and no other change is made to GL state.
Initially, the attribute stack is empty.
Specifies a mask that indicates which attributes to save. Values for mask are listed below.
GL_STACK_OVERFLOW is generated if glPushAttrib is called while the attribute stack is full.
GL_STACK_UNDERFLOW is generated if glPopAttrib is called while the attribute stack is empty.
GL_INVALID_OPERATION is generated if glPushAttrib or glPopAttrib is executed between the execution of glBegin and the corresponding execution of glEnd .
void glPopClientAttrib()
glPushClientAttrib takes one argument, a mask that indicates which groups of client-state variables to save on the client attribute stack. Symbolic constants are used to set bits in the mask. mask is typically constructed by OR'ing several of these constants together. The special mask GL_CLIENT_ALL_ATTRIB_BITS can be used to save all stackable client state.
The symbolic mask constants and their associated GL client state are as follows (the second column lists which attributes are saved):
GL_CLIENT_PIXEL_STORE_BIT Pixel storage modes
GL_CLIENT_VERTEX_ARRAY_BIT Vertex arrays (and enables)
glPopClientAttrib restores the values of the client-state variables saved with the last glPushClientAttrib . Those not saved are left unchanged.
It is an error to push attributes onto a full client attribute stack, or to pop attributes off an empty stack. In either case, the error flag is set, and no other change is made to GL state.
Initially, the client attribute stack is empty.
Specifies a mask that indicates which attributes to save. Values for mask are listed below.
GL_STACK_OVERFLOW is generated if glPushClientAttrib is called while the attribute stack is full.
GL_STACK_UNDERFLOW is generated if glPopClientAttrib is called while the attribute stack is empty.
void glPopMatrix()
There is a stack of matrices for each of the matrix modes. In GL_MODELVIEW mode, the stack depth is at least 32. In the other two modes, GL_PROJECTION and GL_TEXTURE , the depth is at least 2. The current matrix in any mode is the matrix on the top of the stack for that mode.
glPushMatrix pushes the current matrix stack down by one, duplicating the current matrix. That is, after a glPushMatrix call, the matrix on top of the stack is identical to the one below it.
glPopMatrix pops the current matrix stack, replacing the current matrix with the one below it on the stack.
Initially, each of the stacks contains one matrix, an identity matrix.
It is an error to push a full matrix stack, or to pop a matrix stack that contains only a single matrix. In either case, the error flag is set and no other change is made to GL state.
GL_STACK_OVERFLOW is generated if glPushMatrix is called while the current matrix stack is full.
GL_STACK_UNDERFLOW is generated if glPopMatrix is called while the current matrix stack contains only a single matrix.
GL_INVALID_OPERATION is generated if glPushMatrix or glPopMatrix is executed between the execution of glBegin and the corresponding execution of glEnd .
void glPopName()
The name stack is used during selection mode to allow sets of rendering commands to be uniquely identified. It consists of an ordered set of unsigned integers and is initially empty.
glPushName causes name to be pushed onto the name stack. glPopName pops one name off the top of the stack.
The maximum name stack depth is implementation-dependent; call GL_MAX_NAME_STACK_DEPTH to find out the value for a particular implementation. It is an error to push a name onto a full stack, or to pop a name off an empty stack. It is also an error to manipulate the name stack between the execution of glBegin and the corresponding execution of glEnd . In any of these cases, the error flag is set and no other change is made to GL state.
The name stack is always empty while the render mode is not GL_SELECT . Calls to glPushName or glPopName while the render mode is not GL_SELECT are ignored.
Specifies a name that will be pushed onto the name stack.
GL_STACK_OVERFLOW is generated if glPushName is called while the name stack is full.
GL_STACK_UNDERFLOW is generated if glPopName is called while the name stack is empty.
GL_INVALID_OPERATION is generated if glPushName or glPopName is executed between a call to glBegin and the corresponding call to glEnd .
void glPushMatrix()
There is a stack of matrices for each of the matrix modes. In GL_MODELVIEW mode, the stack depth is at least 32. In the other two modes, GL_PROJECTION and GL_TEXTURE , the depth is at least 2. The current matrix in any mode is the matrix on the top of the stack for that mode.
glPushMatrix pushes the current matrix stack down by one, duplicating the current matrix. That is, after a glPushMatrix call, the matrix on top of the stack is identical to the one below it.
glPopMatrix pops the current matrix stack, replacing the current matrix with the one below it on the stack.
Initially, each of the stacks contains one matrix, an identity matrix.
It is an error to push a full matrix stack, or to pop a matrix stack that contains only a single matrix. In either case, the error flag is set and no other change is made to GL state.
GL_STACK_OVERFLOW is generated if glPushMatrix is called while the current matrix stack is full.
GL_STACK_UNDERFLOW is generated if glPopMatrix is called while the current matrix stack contains only a single matrix.
GL_INVALID_OPERATION is generated if glPushMatrix or glPopMatrix is executed between the execution of glBegin and the corresponding execution of glEnd .
void glBegin(int mode)
glBegin and glEnd delimit the vertices that define a primitive or a group of like primitives. glBegin accepts a single argument that specifies in which of ten ways the vertices are interpreted. Taking n as an integer count starting at one, and N as the total number of vertices specified, the interpretations are as follows:
|
Only a subset of GL commands can be used between glBegin and glEnd . The commands are glVertex , glColor , glIndex , glNormal , glTexCoord , glEvalCoord , glEvalPoint , glArrayElement , glMaterial , and glEdgeFlag . Also, it is acceptable to use glCallList or glCallLists to execute display lists that include only the preceding commands. If any other GL command is executed between glBegin and glEnd , the error flag is set and the command is ignored.
Regardless of the value chosen for mode, there is no limit to the number of vertices that can be defined between glBegin and glEnd . Lines, triangles, quadrilaterals, and polygons that are incompletely specified are not drawn. Incomplete specification results when either too few vertices are provided to specify even a single primitive or when an incorrect multiple of vertices is specified. The incomplete primitive is ignored; the rest are drawn.
The minimum specification of vertices for each primitive is as follows: 1 for a point, 2 for a line, 3 for a triangle, 4 for a quadrilateral, and 3 for a polygon. Modes that require a certain multiple of vertices are GL_LINES (2), GL_TRIANGLES (3), GL_QUADS (4), and GL_QUAD_STRIP (2).
Specifies the primitive or primitives that will be created from vertices presented between glBegin and the subsequent glEnd . Ten symbolic constants are accepted: GL_POINTS , GL_LINES , GL_LINE_STRIP , GL_LINE_LOOP , GL_TRIANGLES , GL_TRIANGLE_STRIP , GL_TRIANGLE_FAN , GL_QUADS , GL_QUAD_STRIP , and GL_POLYGON .
GL_INVALID_ENUM is generated if mode is set to an unaccepted value.
GL_INVALID_OPERATION is generated if glBegin is executed between a glBegin and the corresponding execution of glEnd .
GL_INVALID_OPERATION is generated if glEnd is executed without being preceded by a glBegin .
GL_INVALID_OPERATION is generated if a command other than glVertex , glColor , glIndex , glNormal , glTexCoord , glEvalCoord , glEvalPoint , glArrayElement , glMaterial , glEdgeFlag , glCallList , or glCallLists is executed between the execution of glBegin and the corresponding execution glEnd .
Execution of glEnableClientState , glDisableClientState , glEdgeFlagPointer , glTexCoordPointer , glColorPointer , glIndexPointer , glNormalPointer ,
glVertexPointer , glInterleavedArrays , or glPixelStore is not allowed after a call to glBegin and before the corresponding call to glEnd , but an error may or may not be generated.
void glCullFace(int mode)
glCullFace specifies whether front- or back-facing facets are culled (as specified by mode) when facet culling is enabled. Facet culling is initially disabled. To enable and disable facet culling, call the glEnable and glDisable commands with the argument GL_CULL_FACE . Facets include triangles, quadrilaterals, polygons, and rectangles.
glFrontFace specifies which of the clockwise and counterclockwise facets are front-facing and back-facing. See glFrontFace .
Specifies whether front- or back-facing facets are candidates for culling. Symbolic constants GL_FRONT , GL_BACK , and GL_FRONT_AND_BACK are accepted. The initial value is GL_BACK .
GL_INVALID_ENUM is generated if mode is not an accepted value.
GL_INVALID_OPERATION is generated if glCullFace is executed between the execution of glBegin and the corresponding execution of glEnd .
void glDepthFunc(int func)
glDepthFunc specifies the function used to compare each incoming pixel depth value with the depth value present in the depth buffer. The comparison is performed only if depth testing is enabled. (See glEnable and glDisable of GL_DEPTH_TEST .)
func specifies the conditions under which the pixel will be drawn. The comparison functions are as follows:
|
The initial value of func is GL_LESS . Initially, depth testing is disabled. .NOTES Even if the depth buffer exists and the depth mask is non-zero, the depth buffer is not updated if the depth test is disabled.
Specifies the depth comparison function. Symbolic constants GL_NEVER , GL_LESS , GL_EQUAL , GL_LEQUAL , GL_GREATER , GL_NOTEQUAL , GL_GEQUAL , and GL_ALWAYS are accepted. The initial value is GL_LESS .
GL_INVALID_ENUM is generated if func is not an accepted value.
GL_INVALID_OPERATION is generated if glDepthFunc is executed between the execution of glBegin and the corresponding execution of glEnd .
void glDisable(int cap)
glEnable and glDisable enable and disable various capabilities. Use glIsEnabled or glGet to determine the current setting of any capability. The initial value for each capability with the exception of GL_DITHER is GL_FALSE . The initial value for GL_DITHER is GL_TRUE .
Both glEnable and glDisable take a single argument, cap, which can assume one of the following values:
|
Specifies a symbolic constant indicating a GL capability.
Specifies a symbolic constant indicating a GL capability.
GL_INVALID_ENUM is generated if cap is not one of the values listed previously.
GL_INVALID_OPERATION is generated if glEnable or glDisable is executed between the execution of glBegin and the corresponding execution of glEnd .
void glDisableClientState(int cap)
glEnableClientState and glDisableClientState enable or disable individual client-side capabilities. By default, all client-side capabilities are disabled. Both glEnableClientState and glDisableClientState take a single argument, cap, which can assume one of the following values:
|
Specifies the capability to enable. Symbolic constants GL_COLOR_ARRAY , GL_EDGE_FLAG_ARRAY , GL_INDEX_ARRAY , GL_NORMAL_ARRAY , GL_TEXTURE_COORD_ARRAY , and GL_VERTEX_ARRAY are accepted.
Specifies the capability to disable.
GL_INVALID_ENUM is generated if cap is not an accepted value.
glEnableClientState is not allowed between the execution of glBegin and the corresponding glEnd , but an error may or may not be generated. If no error is generated, the behavior is undefined.
void glDrawBuffer(int mode)
When colors are written to the frame buffer, they are written into the color buffers specified by glDrawBuffer . The specifications are as follows:
|
If more than one color buffer is selected for drawing, then blending or logical operations are computed and applied independently for each color buffer and can produce different results in each buffer.
Monoscopic contexts include only .I left buffers, and stereoscopic contexts include both .I left and .I right buffers. Likewise, single-buffered contexts include only .I front buffers, and double-buffered contexts include both .I front and .I back buffers. The context is selected at GL initialization.
Specifies up to four color buffers to be drawn into. Symbolic constants GL_NONE , GL_FRONT_LEFT , GL_FRONT_RIGHT , GL_BACK_LEFT , GL_BACK_RIGHT , GL_FRONT , GL_BACK , GL_LEFT , GL_RIGHT , GL_FRONT_AND_BACK , and GL_AUXi, where i is between 0 and ``GL_AUX_BUFFERS '' -1, are accepted (GL_AUX_BUFFERS is not the upper limit; use glGet to query the number of available aux buffers.) The initial value is GL_FRONT for single-buffered contexts, and GL_BACK for double-buffered contexts.
GL_INVALID_ENUM is generated if mode is not an accepted value.
GL_INVALID_OPERATION is generated if none of the buffers indicated by mode exists.
GL_INVALID_OPERATION is generated if glDrawBuffer is executed between the execution of glBegin and the corresponding execution of glEnd .
void glEnable(int cap)
glEnable and glDisable enable and disable various capabilities. Use glIsEnabled or glGet to determine the current setting of any capability. The initial value for each capability with the exception of GL_DITHER is GL_FALSE . The initial value for GL_DITHER is GL_TRUE .
Both glEnable and glDisable take a single argument, cap, which can assume one of the following values:
|
Specifies a symbolic constant indicating a GL capability.
Specifies a symbolic constant indicating a GL capability.
GL_INVALID_ENUM is generated if cap is not one of the values listed previously.
GL_INVALID_OPERATION is generated if glEnable or glDisable is executed between the execution of glBegin and the corresponding execution of glEnd .
void glEnableClientState(int cap)
glEnableClientState and glDisableClientState enable or disable individual client-side capabilities. By default, all client-side capabilities are disabled. Both glEnableClientState and glDisableClientState take a single argument, cap, which can assume one of the following values:
|
Specifies the capability to enable. Symbolic constants GL_COLOR_ARRAY , GL_EDGE_FLAG_ARRAY , GL_INDEX_ARRAY , GL_NORMAL_ARRAY , GL_TEXTURE_COORD_ARRAY , and GL_VERTEX_ARRAY are accepted.
Specifies the capability to disable.
GL_INVALID_ENUM is generated if cap is not an accepted value.
glEnableClientState is not allowed between the execution of glBegin and the corresponding glEnd , but an error may or may not be generated. If no error is generated, the behavior is undefined.
void glFrontFace(int mode)
In a scene composed entirely of opaque closed surfaces, back-facing polygons are never visible. Eliminating these invisible polygons has the obvious benefit of speeding up the rendering of the image. To enable and disable elimination of back-facing polygons, call glEnable and glDisable with argument GL_CULL_FACE .
The projection of a polygon to window coordinates is said to have clockwise winding if an imaginary object following the path from its first vertex, its second vertex, and so on, to its last vertex, and finally back to its first vertex, moves in a clockwise direction about the interior of the polygon. The polygon's winding is said to be counterclockwise if the imaginary object following the same path moves in a counterclockwise direction about the interior of the polygon. glFrontFace specifies whether polygons with clockwise winding in window coordinates, or counterclockwise winding in window coordinates, are taken to be front-facing. Passing GL_CCW to mode selects counterclockwise polygons as front-facing; GL_CW selects clockwise polygons as front-facing. By default, counterclockwise polygons are taken to be front-facing.
Specifies the orientation of front-facing polygons. GL_CW and GL_CCW are accepted. The initial value is GL_CCW .
GL_INVALID_ENUM is generated if mode is not an accepted value.
GL_INVALID_OPERATION is generated if glFrontFace is executed between the execution of glBegin and the corresponding execution of glEnd .
void glLogicOp(int opcode)
glLogicOp specifies a logical operation that, when enabled, is applied between the incoming color index or RGBA color and the color index or RGBA color at the corresponding location in the frame buffer. To enable or disable the logical operation, call glEnable and glDisable using the symbolic constant GL_COLOR_LOGIC_OP for RGBA mode or GL_INDEX_LOGIC_OP for color index mode. The initial value is disabled for both operations.
.ne .TS center box ; ci | ci c | c . opcode resulting value = GL_CLEAR 0 GL_SET 1 GL_COPY s GL_COPY_INVERTED ~s GL_NOOP d GL_INVERT ~d GL_AND s & d GL_NAND ~(s & d) GL_OR s | d GL_NOR ~(s | d) GL_XOR s ^ d GL_EQUIV ~(s ^ d) GL_AND_REVERSE s & ~d GL_AND_INVERTED ~s & d GL_OR_REVERSE s | ~d GL_OR_INVERTED ~s | d .TE
opcode is a symbolic constant chosen from the list above. In the explanation of the logical operations, s represents the incoming color index and d represents the index in the frame buffer. Standard C-language operators are used. As these bitwise operators suggest, the logical operation is applied independently to each bit pair of the source and destination indices or colors.
Specifies a symbolic constant that selects a logical operation. The following symbols are accepted: GL_CLEAR , GL_SET , GL_COPY , GL_COPY_INVERTED , GL_NOOP , GL_INVERT , GL_AND , GL_NAND , GL_OR , GL_NOR , GL_XOR , GL_EQUIV , GL_AND_REVERSE , GL_AND_INVERTED , GL_OR_REVERSE , and GL_OR_INVERTED . The initial value is GL_COPY .
GL_INVALID_ENUM is generated if opcode is not an accepted value.
GL_INVALID_OPERATION is generated if glLogicOp is executed between the execution of glBegin and the corresponding execution of glEnd .
void glMatrixMode(int mode)
glMatrixMode sets the current matrix mode. mode can assume one of three values:
|
To find out which matrix stack is currently the target of all matrix operations, call glGet with argument GL_MATRIX_MODE . The initial value is GL_MODELVIEW .
Specifies which matrix stack is the target for subsequent matrix operations. Three values are accepted: GL_MODELVIEW , GL_PROJECTION , and GL_TEXTURE . The initial value is GL_MODELVIEW .
GL_INVALID_ENUM is generated if mode is not an accepted value.
GL_INVALID_OPERATION is generated if glMatrixMode is executed between the execution of glBegin and the corresponding execution of glEnd .
void glReadBuffer(int mode)
glReadBuffer specifies a color buffer as the source for subsequent glReadPixels , glCopyTexImage1D , glCopyTexImage2D , glCopyTexSubImage1D , glCopyTexSubImage2D , and glCopyPixels commands. mode accepts one of twelve or more predefined values. (GL_AUX0 through GL_AUX3 are always defined.) In a fully configured system, GL_FRONT , GL_LEFT , and GL_FRONT_LEFT all name the front left buffer, GL_FRONT_RIGHT and GL_RIGHT name the front right buffer, and GL_BACK_LEFT and GL_BACK name the back left buffer.
Nonstereo double-buffered configurations have only a front left and a back left buffer. Single-buffered configurations have a front left and a front right buffer if stereo, and only a front left buffer if nonstereo. It is an error to specify a nonexistent buffer to glReadBuffer .
mode is initially GL_FRONT in single-buffered configurations, and GL_BACK in double-buffered configurations.
Specifies a color buffer. Accepted values are GL_FRONT_LEFT , GL_FRONT_RIGHT , GL_BACK_LEFT , GL_BACK_RIGHT , GL_FRONT , GL_BACK , GL_LEFT , GL_RIGHT , and GL_AUXi, where i is between 0 and GL_AUX_BUFFERS -1.
GL_INVALID_ENUM is generated if mode is not one of the twelve (or more) accepted values.
GL_INVALID_OPERATION is generated if mode specifies a buffer that does not exist.
GL_INVALID_OPERATION is generated if glReadBuffer is executed between the execution of glBegin and the corresponding execution of glEnd .
void glRenderMode(int mode)
glRenderMode sets the rasterization mode. It takes one argument, mode, which can assume one of three predefined values:
|
The return value of glRenderMode is determined by the render mode at the time glRenderMode is called, rather than by mode. The values returned for the three render modes are as follows:
|
See the glSelectBuffer and glFeedbackBuffer reference pages for more details concerning selection and feedback operation.
Specifies the rasterization mode. Three values are accepted: GL_RENDER , GL_SELECT , and GL_FEEDBACK . The initial value is GL_RENDER .
GL_INVALID_ENUM is generated if mode is not one of the three accepted values.
GL_INVALID_OPERATION is generated if glSelectBuffer is called while the render mode is GL_SELECT , or if glRenderMode is called with argument GL_SELECT before glSelectBuffer is called at least once.
GL_INVALID_OPERATION is generated if glFeedbackBuffer is called while the render mode is GL_FEEDBACK , or if glRenderMode is called with argument GL_FEEDBACK before glFeedbackBuffer is called at least once.
GL_INVALID_OPERATION is generated if glRenderMode is executed between the execution of glBegin and the corresponding execution of glEnd .
void glShadeModel(int mode)
GL primitives can have either flat or smooth shading. Smooth shading, the default, causes the computed colors of vertices to be interpolated as the primitive is rasterized, typically assigning different colors to each resulting pixel fragment. Flat shading selects the computed color of just one vertex and assigns it to all the pixel fragments generated by rasterizing a single primitive. In either case, the computed color of a vertex is the result of lighting if lighting is enabled, or it is the current color at the time the vertex was specified if lighting is disabled.
Flat and smooth shading are indistinguishable for points. Starting when glBegin is issued and counting vertices and primitives from 1, the GL gives each flat-shaded line segment i the computed color of vertex i + 1, its second vertex. Counting similarly from 1, the GL gives each flat-shaded polygon the computed color of the vertex listed in the following table. This is the last vertex to specify the polygon in all cases except single polygons, where the first vertex specifies the flat-shaded color. .sp .TS center box; l | c . primitive type of polygon i vertex = Single polygon ( i == 1 ) 1 Triangle strip i + 2 Triangle fan i + 2 Independent triangle 3 i Quad strip 2 i + 2 Independent quad 4 i .TE .sp Flat and smooth shading are specified by glShadeModel with mode set to GL_FLAT and GL_SMOOTH , respectively.
Specifies a symbolic value representing a shading technique. Accepted values are GL_FLAT and GL_SMOOTH . The initial value is GL_SMOOTH .
GL_INVALID_ENUM is generated if mode is any value other than GL_FLAT or GL_SMOOTH .
GL_INVALID_OPERATION is generated if glShadeModel is executed between the execution of glBegin and the corresponding execution of glEnd .
constant GL.GL_2D
Used in glFeedbackBuffer
constant GL.GL_2_BYTES
Used in glCallLists
constant GL.GL_3D
Used in glFeedbackBuffer
constant GL.GL_3D_COLOR
Used in glFeedbackBuffer
constant GL.GL_3D_COLOR_TEXTURE
Used in glFeedbackBuffer
constant GL.GL_3_BYTES
Used in glCallLists
constant GL.GL_4D_COLOR_TEXTURE
Used in glFeedbackBuffer
constant GL.GL_4_BYTES
Used in glCallLists
constant GL.GL_ABGR_EXT
constant GL.GL_ACCUM
Used in glGetIntegerv , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv , glAccum , glGetDoublev and glClear
constant GL.GL_ACCUM_ALPHA_BITS
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glAccum and glGetDoublev
constant GL.GL_ACCUM_BLUE_BITS
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glAccum and glGetDoublev
constant GL.GL_ACCUM_BUFFER_BIT
Used in glPopAttrib , glPushAttrib and glClear
constant GL.GL_ACCUM_CLEAR_VALUE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_ACCUM_GREEN_BITS
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glAccum and glGetDoublev
constant GL.GL_ACCUM_RED_BITS
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glAccum and glGetDoublev
constant GL.GL_ADD
Used in glAccum
constant GL.GL_ALL_ATTRIB_BITS
Used in glPopAttrib and glPushAttrib
constant GL.GL_ALPHA
Used in glIsEnabled , glTexEnv , glGetIntegerv , glDrawPixels , glDisable , glCopyTexImage1D , glTexSubImage2D , glPopAttrib , glEnable , glPixelTransfer , glGetBooleanv , glGetTexImage , glPushAttrib , glGetFloatv , glGetDoublev , glAlphaFunc , glReadPixels , glCopyTexImage2D , glTexImage2D , glTexSubImage1D and glTexImage1D
constant GL.GL_ALPHA12
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_ALPHA16
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_ALPHA4
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_ALPHA8
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_ALPHA_BIAS
Used in glGetIntegerv , glPopAttrib , glPixelTransfer , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_ALPHA_BITS
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_ALPHA_SCALE
Used in glGetIntegerv , glPopAttrib , glPixelTransfer , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_ALPHA_TEST
Used in glIsEnabled , glGetIntegerv , glDisable , glPopAttrib , glEnable , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev and glAlphaFunc
constant GL.GL_ALPHA_TEST_FUNC
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_ALPHA_TEST_REF
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_ALWAYS
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev , glAlphaFunc , glDepthFunc and glStencilFunc
constant GL.GL_AMBIENT
Used in glGetIntegerv , glColorMaterial , glGetLight , glGetBooleanv , glGetFloatv , glMaterial , glGetDoublev , glLight and glGetMaterial
constant GL.GL_AMBIENT_AND_DIFFUSE
Used in glGetIntegerv , glColorMaterial , glGetBooleanv , glGetFloatv , glMaterial and glGetDoublev
constant GL.GL_AND
Used in glLogicOp
constant GL.GL_AND_INVERTED
Used in glLogicOp
constant GL.GL_AND_REVERSE
Used in glLogicOp
constant GL.GL_ATTRIB_STACK_DEPTH
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_AUTO_NORMAL
Used in glIsEnabled , glGetIntegerv , glDisable , glPopAttrib , glEnable , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev and glEvalCoord
constant GL.GL_AUX0
Used in glReadBuffer
constant GL.GL_AUX1
constant GL.GL_AUX2
constant GL.GL_AUX3
Used in glReadBuffer
constant GL.GL_AUX_BUFFERS
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glReadBuffer , glGetDoublev and glDrawBuffer
constant GL.GL_AVERAGE_EXT
constant GL.GL_BACK
Used in glGetIntegerv , glColorMaterial , glCullFace , glPolygonMode , glGetBooleanv , glGetFloatv , glReadBuffer , glMaterial , glGetDoublev , glDrawBuffer and glGetMaterial
constant GL.GL_BACK_LEFT
Used in glReadBuffer and glDrawBuffer
constant GL.GL_BACK_RIGHT
Used in glReadBuffer and glDrawBuffer
constant GL.GL_BGR
constant GL.GL_BGRA
constant GL.GL_BITMAP
Used in glDrawPixels , glTexSubImage2D , glGetTexImage , glReadPixels , glTexImage2D , glFeedbackBuffer , glGetPolygonStipple , glBitmap , glTexSubImage1D , glTexImage1D and glPolygonStipple
constant GL.GL_BITMAP_TOKEN
Used in glFeedbackBuffer
constant GL.GL_BLEND
Used in glIsEnabled , glTexEnv , glGetIntegerv , glBlendColorEXT , glBlendFunc , glDisable , glPopAttrib , glEnable , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_BLEND_COLOR_EXT
Used in glGetIntegerv , glBlendColorEXT , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_BLEND_DST
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_BLEND_EQUATION_EXT
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_BLEND_SRC
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_BLUE
Used in glGetIntegerv , glDrawPixels , glTexSubImage2D , glPopAttrib , glPixelTransfer , glGetBooleanv , glGetTexImage , glPushAttrib , glGetFloatv , glGetDoublev , glReadPixels , glTexImage2D , glTexSubImage1D and glTexImage1D
constant GL.GL_BLUE_BIAS
Used in glGetIntegerv , glPopAttrib , glPixelTransfer , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_BLUE_BITS
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_BLUE_SCALE
Used in glGetIntegerv , glPopAttrib , glPixelTransfer , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_BYTE
Used in glDrawPixels , glColorPointer , glTexSubImage2D , glNormalPointer , glGetTexImage , glCallLists , glReadPixels , glTexImage2D , glTexSubImage1D and glTexImage1D
constant GL.GL_C3F_V3F
Used in glInterleavedArrays
constant GL.GL_C4F_N3F_V3F
Used in glInterleavedArrays
constant GL.GL_C4UB_V2F
Used in glInterleavedArrays
constant GL.GL_C4UB_V3F
Used in glInterleavedArrays
constant GL.GL_CCW
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev and glFrontFace
constant GL.GL_CLAMP
Used in glTexParameter
constant GL.GL_CLEAR
Used in glLogicOp
constant GL.GL_CLIENT_ALL_ATTRIB_BITS
Used in glPopClientAttrib and glPushClientAttrib
constant GL.GL_CLIENT_ATTRIB_STACK_DEPTH
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_CLIENT_PIXEL_STORE_BIT
Used in glPopClientAttrib and glPushClientAttrib
constant GL.GL_CLIENT_VERTEX_ARRAY_BIT
Used in glPopClientAttrib and glPushClientAttrib
constant GL.GL_CLIP_PLANE0
constant GL.GL_CLIP_PLANE1
constant GL.GL_CLIP_PLANE2
constant GL.GL_CLIP_PLANE3
constant GL.GL_CLIP_PLANE4
constant GL.GL_CLIP_PLANE5
constant GL.GL_COEFF
Used in glGetMap
constant GL.GL_COLOR
Used in glIsEnabled , glGetIntegerv , glDrawElements , glDrawArrays , glColorMaterial , glDrawPixels , glDisable , glColorPointer , glTexSubImage2D , glPopAttrib , glEnable , glEnableClientState , glGetPointerv , glPixelTransfer , glLogicOp , glGetBooleanv , glGetTexImage , glPushAttrib , glGetFloatv , glMaterial , glGetDoublev , glReadPixels , glTexImage2D , glGetPolygonStipple , glBitmap , glCopyPixels , glLightModel , glDisableClientState , glTexSubImage1D , glTexImage1D , glGetMaterial , glClear and glPolygonStipple
constant GL.GL_COLOR_ARRAY
Used in glIsEnabled , glGetIntegerv , glDrawElements , glDrawArrays , glColorPointer , glEnableClientState , glGetPointerv , glGetBooleanv , glGetFloatv , glGetDoublev and glDisableClientState
constant GL.GL_COLOR_ARRAY_POINTER
Used in glGetPointerv
constant GL.GL_COLOR_ARRAY_SIZE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_COLOR_ARRAY_STRIDE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_COLOR_ARRAY_TYPE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_COLOR_BUFFER_BIT
Used in glPopAttrib , glPushAttrib and glClear
constant GL.GL_COLOR_CLEAR_VALUE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_COLOR_INDEX
Used in glDrawPixels , glTexSubImage2D , glPixelTransfer , glGetTexImage , glMaterial , glReadPixels , glTexImage2D , glGetPolygonStipple , glBitmap , glLightModel , glTexSubImage1D , glTexImage1D , glGetMaterial and glPolygonStipple
constant GL.GL_COLOR_INDEXES
Used in glMaterial , glLightModel and glGetMaterial
constant GL.GL_COLOR_LOGIC_OP
Used in glIsEnabled , glGetIntegerv , glDisable , glPopAttrib , glEnable , glLogicOp , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_COLOR_MATERIAL
Used in glIsEnabled , glGetIntegerv , glColorMaterial , glDisable , glPopAttrib , glEnable , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_COLOR_MATERIAL_FACE
Used in glGetIntegerv , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_COLOR_MATERIAL_PARAMETER
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_COLOR_TABLE_ALPHA_SIZE_SGI
constant GL.GL_COLOR_TABLE_BIAS_SGI
constant GL.GL_COLOR_TABLE_BLUE_SIZE_SGI
constant GL.GL_COLOR_TABLE_FORMAT_SGI
constant GL.GL_COLOR_TABLE_GREEN_SIZE_SGI
constant GL.GL_COLOR_TABLE_INTENSITY_SIZE_SGI
constant GL.GL_COLOR_TABLE_LUMINANCE_SIZE_SGI
constant GL.GL_COLOR_TABLE_RED_SIZE_SGI
constant GL.GL_COLOR_TABLE_SCALE_SGI
constant GL.GL_COLOR_TABLE_SGI
constant GL.GL_COLOR_TABLE_WIDTH_SGI
constant GL.GL_COLOR_WRITEMASK
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_COMPILE
Used in glNewList and glEndList
constant GL.GL_COMPILE_AND_EXECUTE
Used in glNewList and glEndList
constant GL.GL_COMPRESSED_GEOM_ACCELERATED_SUNX
constant GL.GL_COMPRESSED_GEOM_VERSION_SUNX
constant GL.GL_CONSTANT_ALPHA_EXT
constant GL.GL_CONSTANT_ATTENUATION
Used in glGetLight and glLight
constant GL.GL_CONSTANT_BORDER_HP
constant GL.GL_CONSTANT_COLOR_EXT
constant GL.GL_CONVOLUTION_1D_EXT
constant GL.GL_CONVOLUTION_2D_EXT
constant GL.GL_CONVOLUTION_BORDER_COLOR_HP
constant GL.GL_CONVOLUTION_BORDER_MODE_EXT
constant GL.GL_CONVOLUTION_FILTER_BIAS_EXT
constant GL.GL_CONVOLUTION_FILTER_SCALE_EXT
constant GL.GL_CONVOLUTION_FORMAT_EXT
constant GL.GL_CONVOLUTION_HEIGHT_EXT
constant GL.GL_CONVOLUTION_WIDTH_EXT
constant GL.GL_COPY
Used in glGetIntegerv , glLogicOp , glGetBooleanv , glGetFloatv , glGetDoublev and glFeedbackBuffer
constant GL.GL_COPY_INVERTED
Used in glLogicOp
constant GL.GL_COPY_PIXEL_TOKEN
Used in glFeedbackBuffer
constant GL.GL_CUBIC_EXT
constant GL.GL_CULL_FACE
Used in glIsEnabled , glGetIntegerv , glCullFace , glDisable , glPopAttrib , glEnable , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev and glFrontFace
constant GL.GL_CULL_FACE_MODE
Used in glGetIntegerv , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_CURRENT_BIT
Used in glPopAttrib and glPushAttrib
constant GL.GL_CURRENT_COLOR
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev and glRasterPos
constant GL.GL_CURRENT_INDEX
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev and glRasterPos
constant GL.GL_CURRENT_NORMAL
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_CURRENT_RASTER_COLOR
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev and glRasterPos
constant GL.GL_CURRENT_RASTER_DISTANCE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev and glRasterPos
constant GL.GL_CURRENT_RASTER_INDEX
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev and glRasterPos
constant GL.GL_CURRENT_RASTER_POSITION
Used in glGetIntegerv , glDrawPixels , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev and glRasterPos
constant GL.GL_CURRENT_RASTER_POSITION_VALID
Used in glGetIntegerv , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev and glRasterPos
constant GL.GL_CURRENT_RASTER_TEXTURE_COORDS
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev and glRasterPos
constant GL.GL_CURRENT_TEXTURE_COORDS
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev and glRasterPos
constant GL.GL_CW
Used in glFrontFace
constant GL.GL_DECAL
Used in glTexEnv
constant GL.GL_DECR
Used in glStencilOp
constant GL.GL_DEPTH
Used in glIsEnabled , glGetIntegerv , glDrawPixels , glDisable , glPopAttrib , glEnable , glPixelTransfer , glGetBooleanv , glGetTexImage , glPushAttrib , glGetFloatv , glGetDoublev , glReadPixels , glTexImage2D , glCopyPixels , glDepthFunc , glTexImage1D and glClear
constant GL.GL_DEPTH_BIAS
Used in glGetIntegerv , glDrawPixels , glPopAttrib , glPixelTransfer , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev , glReadPixels and glCopyPixels
constant GL.GL_DEPTH_BITS
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_DEPTH_BUFFER_BIT
Used in glPopAttrib , glPushAttrib and glClear
constant GL.GL_DEPTH_CLEAR_VALUE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_DEPTH_COMPONENT
Used in glDrawPixels , glGetTexImage , glReadPixels , glTexImage2D and glTexImage1D
constant GL.GL_DEPTH_FUNC
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_DEPTH_RANGE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_DEPTH_SCALE
Used in glGetIntegerv , glDrawPixels , glPopAttrib , glPixelTransfer , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev , glReadPixels and glCopyPixels
constant GL.GL_DEPTH_TEST
Used in glIsEnabled , glGetIntegerv , glDisable , glPopAttrib , glEnable , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev and glDepthFunc
constant GL.GL_DEPTH_WRITEMASK
Used in glGetIntegerv , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_DIFFUSE
Used in glColorMaterial , glGetLight , glMaterial , glLight and glGetMaterial
constant GL.GL_DITHER
Used in glIsEnabled , glGetIntegerv , glDisable , glPopAttrib , glEnable , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_DOMAIN
Used in glGetMap
constant GL.GL_DONT_CARE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev and glHint
constant GL.GL_DOUBLE
Used in glGetIntegerv , glVertexPointer , glColorPointer , glNormalPointer , glGetBooleanv , glGetFloatv , glGetDoublev , glTexCoordPointer and glIndexPointer
constant GL.GL_DOUBLEBUFFER
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_DRAW_BUFFER
Used in glGetIntegerv , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_DRAW_PIXEL_TOKEN
Used in glFeedbackBuffer
constant GL.GL_DST_ALPHA
Used in glBlendFunc
constant GL.GL_DST_COLOR
Used in glBlendFunc
constant GL.GL_EDGE_FLAG
Used in glIsEnabled , glGetIntegerv , glPopAttrib , glEnableClientState , glGetPointerv , glGetBooleanv , glPushAttrib , glGetFloatv , glEdgeFlagPointer , glGetDoublev and glDisableClientState
constant GL.GL_EDGE_FLAG_ARRAY
Used in glIsEnabled , glGetIntegerv , glEnableClientState , glGetPointerv , glGetBooleanv , glGetFloatv , glEdgeFlagPointer , glGetDoublev and glDisableClientState
constant GL.GL_EDGE_FLAG_ARRAY_POINTER
Used in glGetPointerv
constant GL.GL_EDGE_FLAG_ARRAY_STRIDE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_EMISSION
Used in glColorMaterial , glMaterial and glGetMaterial
constant GL.GL_ENABLE_BIT
Used in glPopAttrib and glPushAttrib
constant GL.GL_EQUAL
Used in glAlphaFunc , glDepthFunc and glStencilFunc
constant GL.GL_EQUIV
Used in glLogicOp
constant GL.GL_EVAL_BIT
Used in glPopAttrib and glPushAttrib
constant GL.GL_EXP
Used in glFog , glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_EXP2
Used in glFog
constant GL.GL_EXTENSIONS
Used in glGetString
constant GL.GL_EXT_abgr
constant GL.GL_EXT_blend_color
constant GL.GL_EXT_blend_minmax
constant GL.GL_EXT_blend_subtract
constant GL.GL_EXT_convolution
constant GL.GL_EXT_histogram
constant GL.GL_EXT_pixel_transform
constant GL.GL_EXT_rescale_normal
constant GL.GL_EXT_texture3D
constant GL.GL_EYE_LINEAR
Used in glGetTexGen and glTexGen
constant GL.GL_EYE_PLANE
Used in glGetTexGen and glTexGen
constant GL.GL_FALSE
Used in glIsEnabled , glDepthMask , glIsList , glAreTexturesResident , glGetIntegerv , glIsTexture , glDisable , glEdgeFlag , glEnable , glColorMask , glGetBooleanv , glGetFloatv , glGetDoublev and glEdgeFlagv
constant GL.GL_FASTEST
Used in glHint
constant GL.GL_FEEDBACK
Used in glRenderMode , glPassThrough , glGetPointerv and glFeedbackBuffer
constant GL.GL_FEEDBACK_BUFFER_POINTER
Used in glGetPointerv
constant GL.GL_FEEDBACK_BUFFER_SIZE
constant GL.GL_FEEDBACK_BUFFER_TYPE
constant GL.GL_FILL
Used in glGetIntegerv , glDisable , glEnable , glPolygonMode , glGetBooleanv , glGetFloatv , glGetDoublev and glEvalMesh
constant GL.GL_FLAT
Used in glShadeModel
constant GL.GL_FLOAT
Used in glGetIntegerv , glDrawPixels , glVertexPointer , glColorPointer , glTexSubImage2D , glNormalPointer , glGetBooleanv , glGetTexImage , glGetFloatv , glGetDoublev , glCallLists , glReadPixels , glTexImage2D , glTexCoordPointer , glIndexPointer , glTexSubImage1D and glTexImage1D
constant GL.GL_FOG
Used in glIsEnabled , glFog , glGetIntegerv , glDisable , glPopAttrib , glEnable , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev and glHint
constant GL.GL_FOG_BIT
Used in glPopAttrib and glPushAttrib
constant GL.GL_FOG_COLOR
Used in glFog , glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_FOG_DENSITY
Used in glFog , glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_FOG_END
Used in glFog , glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_FOG_HINT
Used in glGetIntegerv , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev and glHint
constant GL.GL_FOG_INDEX
Used in glFog , glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_FOG_MODE
Used in glFog , glGetIntegerv , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_FOG_START
Used in glFog , glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_FRONT
Used in glGetIntegerv , glColorMaterial , glCullFace , glPopAttrib , glPolygonMode , glGetBooleanv , glPushAttrib , glGetFloatv , glReadBuffer , glMaterial , glGetDoublev , glDrawBuffer and glGetMaterial
constant GL.GL_FRONT_AND_BACK
Used in glGetIntegerv , glColorMaterial , glCullFace , glPolygonMode , glGetBooleanv , glGetFloatv , glMaterial , glGetDoublev and glDrawBuffer
constant GL.GL_FRONT_FACE
Used in glGetIntegerv , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_FRONT_LEFT
Used in glReadBuffer and glDrawBuffer
constant GL.GL_FRONT_RIGHT
Used in glReadBuffer and glDrawBuffer
constant GL.GL_FUNC_ADD_EXT
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_FUNC_REVERSE_SUBTRACT_EXT
constant GL.GL_FUNC_SUBTRACT_EXT
constant GL.GL_GEQUAL
Used in glAlphaFunc , glDepthFunc and glStencilFunc
constant GL.GL_GREATER
Used in glAlphaFunc , glDepthFunc and glStencilFunc
constant GL.GL_GREEN
Used in glGetIntegerv , glDrawPixels , glTexSubImage2D , glPopAttrib , glPixelTransfer , glGetBooleanv , glGetTexImage , glPushAttrib , glGetFloatv , glGetDoublev , glReadPixels , glTexImage2D , glTexSubImage1D and glTexImage1D
constant GL.GL_GREEN_BIAS
Used in glGetIntegerv , glPopAttrib , glPixelTransfer , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_GREEN_BITS
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_GREEN_SCALE
Used in glGetIntegerv , glPopAttrib , glPixelTransfer , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_HINT_BIT
Used in glPopAttrib and glPushAttrib
constant GL.GL_HISTOGRAM_ALPHA_SIZE_EXT
constant GL.GL_HISTOGRAM_BLUE_SIZE_EXT
constant GL.GL_HISTOGRAM_EXT
constant GL.GL_HISTOGRAM_FORMAT_EXT
constant GL.GL_HISTOGRAM_GREEN_SIZE_EXT
constant GL.GL_HISTOGRAM_LUMINANCE_SIZE_EXT
constant GL.GL_HISTOGRAM_RED_SIZE_EXT
constant GL.GL_HISTOGRAM_SINK_EXT
constant GL.GL_HISTOGRAM_WIDTH_EXT
constant GL.GL_HP_convolution_border_modes
constant GL.GL_HP_occlusion_test
constant GL.GL_IGNORE_BORDER_HP
constant GL.GL_INCR
Used in glStencilOp
constant GL.GL_INDEX_ARRAY
Used in glIsEnabled , glGetIntegerv , glEnableClientState , glGetPointerv , glGetBooleanv , glGetFloatv , glGetDoublev , glIndexPointer and glDisableClientState
constant GL.GL_INDEX_ARRAY_POINTER
Used in glGetPointerv
constant GL.GL_INDEX_ARRAY_STRIDE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_INDEX_ARRAY_TYPE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_INDEX_BITS
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_INDEX_CLEAR_VALUE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_INDEX_LOGIC_OP
Used in glIsEnabled , glGetIntegerv , glDisable , glPopAttrib , glEnable , glLogicOp , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_INDEX_MODE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_INDEX_OFFSET
Used in glGetIntegerv , glDrawPixels , glPopAttrib , glPixelTransfer , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev , glReadPixels , glTexImage2D , glCopyPixels and glTexImage1D
constant GL.GL_INDEX_SHIFT
Used in glGetIntegerv , glDrawPixels , glPopAttrib , glPixelTransfer , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev , glReadPixels , glTexImage2D , glCopyPixels and glTexImage1D
constant GL.GL_INDEX_WRITEMASK
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_INT
Used in glTexEnv , glDrawPixels , glVertexPointer , glColorPointer , glCopyTexImage1D , glTexSubImage2D , glNormalPointer , glGetTexImage , glCallLists , glReadPixels , glCopyTexImage2D , glTexImage2D , glTexCoordPointer , glIndexPointer , glTexSubImage1D and glTexImage1D
constant GL.GL_INTENSITY
Used in glTexEnv , glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_INTENSITY12
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_INTENSITY16
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_INTENSITY4
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_INTENSITY8
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_INVALID_ENUM
Used in glMatrixMode , glPixelStore , glIsEnabled , glGetTexLevelParameter , glFog , glTexEnv , glMap1 , glRenderMode , glGetTexGen , glGetIntegerv , glEnd , glDrawElements , glDrawArrays , glCopyTexSubImage2D , glColorMaterial , glBindTexture , glGetClipPlane , glCullFace , glGetError , glClipPlane , glDrawPixels , glBlendFunc , glVertexPointer , glGetLight , glDisable , glMap2 , glColorPointer , glCopyTexImage1D , glGetPixelMap , glTexSubImage2D , glNormalPointer , glEnable , glEnableClientState , glGetPointerv , glPixelTransfer , glPolygonMode , glGetTexParameter , glLogicOp , glGetBooleanv , glGetTexImage , glPixelMap , glGetFloatv , glGetMap , glAccum , glReadBuffer , glMaterial , glEdgeFlagPointer , glGetDoublev , glCallLists , glInterleavedArrays , glAlphaFunc , glShadeModel , glNewList , glReadPixels , glCopyTexImage2D , glTexImage2D , glGetTexEnv , glFeedbackBuffer , glEndList , glBegin , glLight , glStencilOp , glTexCoordPointer , glCopyPixels , glDepthFunc , glLightModel , glIndexPointer , glGetString , glTexParameter , glDisableClientState , glTexSubImage1D , glDrawBuffer , glHint , glTexImage1D , glStencilFunc , glGetMaterial , glCopyTexSubImage1D , glFrontFace , glEvalMesh and glTexGen
constant GL.GL_INVALID_OPERATION
Used in glPolygonOffset , glPushMatrix , glMatrixMode , glLoadName , glPixelStore , glIsEnabled , glGetTexLevelParameter , glGenTextures , glFog , glTexEnv , glClearColor , glMap1 , glPrioritizeTextures , glDepthMask , glPushName , glRenderMode , glMultMatrix , glIsList , glFrustum , glDepthRange , glAreTexturesResident , glDeleteTextures , glGetTexGen , glGetIntegerv , glEnd , glIsTexture , glDrawElements , glGenLists , glBlendColorEXT , glViewport , glDrawArrays , glCopyTexSubImage2D , glColorMaterial , glBindTexture , glGetClipPlane , glFinish , glCullFace , glGetError , glStencilMask , glClipPlane , glDrawPixels , glBlendFunc , glSelectBuffer , glGetLight , glInitNames , glPassThrough , glDisable , glMap2 , glLineStipple , glCopyTexImage1D , glGetPixelMap , glTexSubImage2D , glPopAttrib , glEnable , glListBase , glColorMask , glPixelTransfer , glPolygonMode , glGetTexParameter , glPopName , glLogicOp , glIndexMask , glGetBooleanv , glGetTexImage , glPixelMap , glTranslate , glPushAttrib , glGetFloatv , glGetMap , glAccum , glReadBuffer , glGetDoublev , glClearDepth , glRasterPos , glAlphaFunc , glShadeModel , glNewList , glReadPixels , glCopyTexImage2D , glRect , glTexImage2D , glGetTexEnv , glClearIndex , glFeedbackBuffer , glRotate , glEndList , glBegin , glLight , glGetPolygonStipple , glStencilOp , glClearStencil , glBitmap , glScale , glCopyPixels , glFlush , glOrtho , glDepthFunc , glMapGrid , glLightModel , glGetString , glTexParameter , glScissor , glTexSubImage1D , glLoadIdentity , glPixelZoom , glDrawBuffer , glLineWidth , glHint , glTexImage1D , glStencilFunc , glGetMaterial , glClear , glCopyTexSubImage1D , glPopMatrix , glPointSize , glPolygonStipple , glFrontFace , glLoadMatrix , glEvalMesh , glTexGen , glClearAccum and glDeleteLists
constant GL.GL_INVALID_VALUE
Used in glPixelStore , glGetTexLevelParameter , glGenTextures , glFog , glMap1 , glPrioritizeTextures , glFrustum , glAreTexturesResident , glDeleteTextures , glDrawElements , glGenLists , glViewport , glDrawArrays , glCopyTexSubImage2D , glGetError , glDrawPixels , glVertexPointer , glSelectBuffer , glMap2 , glColorPointer , glCopyTexImage1D , glTexSubImage2D , glNormalPointer , glGetTexImage , glPixelMap , glMaterial , glCallLists , glInterleavedArrays , glNewList , glReadPixels , glCopyTexImage2D , glTexImage2D , glFeedbackBuffer , glEndList , glLight , glBitmap , glTexCoordPointer , glCopyPixels , glMapGrid , glIndexPointer , glScissor , glTexSubImage1D , glLineWidth , glTexImage1D , glClear , glCopyTexSubImage1D , glPointSize and glDeleteLists
constant GL.GL_INVERT
Used in glLogicOp and glStencilOp
constant GL.GL_KEEP
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev and glStencilOp
constant GL.GL_LARGE_SUNX
constant GL.GL_LEFT
Used in glReadBuffer and glDrawBuffer
constant GL.GL_LEQUAL
Used in glAlphaFunc , glDepthFunc and glStencilFunc
constant GL.GL_LESS
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev , glAlphaFunc , glDepthFunc and glStencilFunc
constant GL.GL_LIGHT0
Used in glGetLight and glLight
constant GL.GL_LIGHT1
constant GL.GL_LIGHT2
constant GL.GL_LIGHT3
constant GL.GL_LIGHT4
constant GL.GL_LIGHT5
constant GL.GL_LIGHT6
constant GL.GL_LIGHT7
constant GL.GL_LIGHTING
Used in glIsEnabled , glGetIntegerv , glDisable , glPopAttrib , glEnable , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev and glLight
constant GL.GL_LIGHTING_BIT
Used in glPopAttrib and glPushAttrib
constant GL.GL_LIGHT_MODEL_AMBIENT
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev and glLightModel
constant GL.GL_LIGHT_MODEL_LOCAL_VIEWER
Used in glGetIntegerv , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev and glLightModel
constant GL.GL_LIGHT_MODEL_TWO_SIDE
Used in glGetIntegerv , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev and glLightModel
constant GL.GL_LINE
Used in glIsEnabled , glFog , glGetIntegerv , glEnd , glDrawElements , glDrawArrays , glGetLight , glDisable , glLineStipple , glEdgeFlag , glPopAttrib , glEnable , glPolygonMode , glGetTexParameter , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev , glFeedbackBuffer , glBegin , glLight , glTexParameter , glLineWidth , glHint , glEdgeFlagv and glEvalMesh
constant GL.GL_LINEAR
Used in glFog , glGetLight , glGetTexParameter , glLight and glTexParameter
constant GL.GL_LINEAR_ATTENUATION
Used in glGetLight and glLight
constant GL.GL_LINEAR_MIPMAP_LINEAR
Used in glTexParameter
constant GL.GL_LINEAR_MIPMAP_NEAREST
Used in glTexParameter
constant GL.GL_LINES
Used in glEnd , glDrawElements , glDrawArrays , glLineStipple , glBegin and glEvalMesh
constant GL.GL_LINE_BIT
Used in glPopAttrib and glPushAttrib
constant GL.GL_LINE_LOOP
Used in glEnd , glDrawElements , glDrawArrays and glBegin
constant GL.GL_LINE_RESET_TOKEN
Used in glFeedbackBuffer
constant GL.GL_LINE_SMOOTH
Used in glIsEnabled , glGetIntegerv , glDisable , glPopAttrib , glEnable , glPolygonMode , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev , glLineWidth and glHint
constant GL.GL_LINE_SMOOTH_HINT
Used in glGetIntegerv , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev and glHint
constant GL.GL_LINE_STIPPLE
Used in glIsEnabled , glGetIntegerv , glDisable , glLineStipple , glPopAttrib , glEnable , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_LINE_STIPPLE_PATTERN
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_LINE_STIPPLE_REPEAT
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_LINE_STRIP
Used in glEnd , glDrawElements , glDrawArrays , glBegin and glEvalMesh
constant GL.GL_LINE_TOKEN
Used in glFeedbackBuffer
constant GL.GL_LINE_WIDTH
Used in glGetIntegerv , glPolygonMode , glGetBooleanv , glGetFloatv , glGetDoublev and glLineWidth
constant GL.GL_LINE_WIDTH_GRANULARITY
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev and glLineWidth
constant GL.GL_LINE_WIDTH_RANGE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev and glLineWidth
constant GL.GL_LIST_BASE
Used in glGetIntegerv , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_LIST_BIT
Used in glPopAttrib and glPushAttrib
constant GL.GL_LIST_INDEX
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_LIST_MODE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_LOAD
Used in glAccum
constant GL.GL_LOGIC_OP
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_LOGIC_OP_MODE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_LUMINANCE
Used in glTexEnv , glDrawPixels , glCopyTexImage1D , glTexSubImage2D , glGetTexImage , glReadPixels , glCopyTexImage2D , glTexImage2D , glTexSubImage1D and glTexImage1D
constant GL.GL_LUMINANCE12
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_LUMINANCE12_ALPHA12
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_LUMINANCE12_ALPHA4
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_LUMINANCE16
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_LUMINANCE16_ALPHA16
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_LUMINANCE4
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_LUMINANCE4_ALPHA4
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_LUMINANCE6_ALPHA2
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_LUMINANCE8
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_LUMINANCE8_ALPHA8
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_LUMINANCE_ALPHA
Used in glDrawPixels , glCopyTexImage1D , glTexSubImage2D , glGetTexImage , glReadPixels , glCopyTexImage2D , glTexImage2D , glTexSubImage1D and glTexImage1D
constant GL.GL_MAP1_COLOR_4
Used in glIsEnabled , glMap1 , glGetIntegerv , glDisable , glEnable , glGetBooleanv , glGetFloatv , glGetMap , glGetDoublev and glEvalCoord
constant GL.GL_MAP1_GRID_DOMAIN
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_MAP1_GRID_SEGMENTS
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_MAP1_INDEX
Used in glMap1 , glGetIntegerv , glDisable , glEnable , glGetBooleanv , glGetFloatv , glGetMap , glGetDoublev and glEvalCoord
constant GL.GL_MAP1_NORMAL
Used in glMap1 , glGetIntegerv , glDisable , glEnable , glGetBooleanv , glGetFloatv , glGetMap , glGetDoublev and glEvalCoord
constant GL.GL_MAP1_TEXTURE_COORD_1
Used in glMap1 , glGetIntegerv , glDisable , glEnable , glGetBooleanv , glGetFloatv , glGetMap , glGetDoublev and glEvalCoord
constant GL.GL_MAP1_TEXTURE_COORD_2
Used in glMap1 , glGetIntegerv , glDisable , glEnable , glGetBooleanv , glGetFloatv , glGetMap , glGetDoublev and glEvalCoord
constant GL.GL_MAP1_TEXTURE_COORD_3
Used in glMap1 , glGetIntegerv , glDisable , glEnable , glGetBooleanv , glGetFloatv , glGetMap , glGetDoublev and glEvalCoord
constant GL.GL_MAP1_TEXTURE_COORD_4
Used in glMap1 , glGetIntegerv , glDisable , glEnable , glGetBooleanv , glGetFloatv , glGetMap , glGetDoublev and glEvalCoord
constant GL.GL_MAP1_VERTEX_3
Used in glMap1 , glGetIntegerv , glDisable , glEnable , glGetBooleanv , glGetFloatv , glGetMap , glGetDoublev and glEvalCoord
constant GL.GL_MAP1_VERTEX_4
Used in glMap1 , glGetIntegerv , glDisable , glEnable , glGetBooleanv , glGetFloatv , glGetMap , glGetDoublev and glEvalCoord
constant GL.GL_MAP2_COLOR_4
Used in glGetIntegerv , glDisable , glMap2 , glEnable , glGetBooleanv , glGetFloatv , glGetMap , glGetDoublev and glEvalCoord
constant GL.GL_MAP2_GRID_DOMAIN
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_MAP2_GRID_SEGMENTS
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_MAP2_INDEX
Used in glGetIntegerv , glDisable , glMap2 , glEnable , glGetBooleanv , glGetFloatv , glGetMap , glGetDoublev and glEvalCoord
constant GL.GL_MAP2_NORMAL
Used in glGetIntegerv , glDisable , glMap2 , glEnable , glGetBooleanv , glGetFloatv , glGetMap , glGetDoublev and glEvalCoord
constant GL.GL_MAP2_TEXTURE_COORD_1
Used in glGetIntegerv , glDisable , glMap2 , glEnable , glGetBooleanv , glGetFloatv , glGetMap , glGetDoublev and glEvalCoord
constant GL.GL_MAP2_TEXTURE_COORD_2
Used in glIsEnabled , glGetIntegerv , glDisable , glMap2 , glEnable , glGetBooleanv , glGetFloatv , glGetMap , glGetDoublev and glEvalCoord
constant GL.GL_MAP2_TEXTURE_COORD_3
Used in glIsEnabled , glGetIntegerv , glDisable , glMap2 , glEnable , glGetBooleanv , glGetFloatv , glGetMap , glGetDoublev and glEvalCoord
constant GL.GL_MAP2_TEXTURE_COORD_4
Used in glIsEnabled , glGetIntegerv , glDisable , glMap2 , glEnable , glGetBooleanv , glGetFloatv , glGetMap , glGetDoublev and glEvalCoord
constant GL.GL_MAP2_VERTEX_3
Used in glIsEnabled , glGetIntegerv , glDisable , glMap2 , glEnable , glGetBooleanv , glGetFloatv , glGetMap , glGetDoublev and glEvalCoord
constant GL.GL_MAP2_VERTEX_4
Used in glIsEnabled , glGetIntegerv , glDisable , glMap2 , glEnable , glGetBooleanv , glGetFloatv , glGetMap , glGetDoublev and glEvalCoord
constant GL.GL_MAP_COLOR
Used in glGetIntegerv , glDrawPixels , glPopAttrib , glPixelTransfer , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev , glReadPixels and glCopyPixels
constant GL.GL_MAP_STENCIL
Used in glGetIntegerv , glDrawPixels , glPopAttrib , glPixelTransfer , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev , glReadPixels and glCopyPixels
constant GL.GL_MATRIX_MODE
Used in glMatrixMode , glGetIntegerv , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_MAX_3D_TEXTURE_SIZE_EXT
constant GL.GL_MAX_ATTRIB_STACK_DEPTH
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_MAX_CLIENT_ATTRIB_STACK_DEPTH
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_MAX_CLIP_PLANES
Used in glGetIntegerv , glGetClipPlane , glClipPlane , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_MAX_CONVOLUTION_HEIGHT_EXT
constant GL.GL_MAX_CONVOLUTION_WIDTH_EXT
constant GL.GL_MAX_EVAL_ORDER
Used in glMap1 , glGetIntegerv , glMap2 , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_MAX_EXT
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_MAX_LIGHTS
Used in glGetIntegerv , glGetLight , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev and glLight
constant GL.GL_MAX_LIST_NESTING
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_MAX_MODELVIEW_STACK_DEPTH
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_MAX_NAME_STACK_DEPTH
Used in glPushName , glGetIntegerv , glPopName , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_MAX_PIXEL_MAP_TABLE
Used in glGetIntegerv , glGetBooleanv , glPixelMap , glGetFloatv and glGetDoublev
constant GL.GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT
constant GL.GL_MAX_PROJECTION_STACK_DEPTH
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_MAX_TEXTURE_SIZE
Used in glGetTexLevelParameter , glGetIntegerv , glCopyTexSubImage2D , glCopyTexImage1D , glTexSubImage2D , glGetBooleanv , glGetTexImage , glGetFloatv , glGetDoublev , glCopyTexImage2D , glTexImage2D , glTexSubImage1D , glTexImage1D and glCopyTexSubImage1D
constant GL.GL_MAX_TEXTURE_STACK_DEPTH
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_MAX_VIEWPORT_DIMS
Used in glGetIntegerv , glViewport , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_MINMAX_EXT
constant GL.GL_MINMAX_FORMAT_EXT
constant GL.GL_MINMAX_SINK_EXT
constant GL.GL_MIN_EXT
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_MODELVIEW
Used in glPushMatrix , glMatrixMode , glGetIntegerv , glGetBooleanv , glTranslate , glGetFloatv , glGetDoublev , glRotate , glScale and glPopMatrix
constant GL.GL_MODELVIEW_MATRIX
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_MODELVIEW_STACK_DEPTH
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_MODULATE
Used in glTexEnv and glGetTexEnv
constant GL.GL_MULT
Used in glAccum
constant GL.GL_N3F_V3F
Used in glInterleavedArrays
constant GL.GL_NAME_STACK_DEPTH
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_NAND
Used in glLogicOp
constant GL.GL_NEAREST
Used in glGetTexParameter and glTexParameter
constant GL.GL_NEAREST_MIPMAP_LINEAR
Used in glGetTexParameter and glTexParameter
constant GL.GL_NEAREST_MIPMAP_NEAREST
Used in glTexParameter
constant GL.GL_NEVER
Used in glAlphaFunc , glDepthFunc and glStencilFunc
constant GL.GL_NICEST
Used in glHint
constant GL.GL_NONE
Used in glDrawBuffer
constant GL.GL_NOOP
Used in glLogicOp
constant GL.GL_NOR
Used in glIsEnabled , glGetIntegerv , glDisable , glNormalPointer , glPopAttrib , glEnable , glEnableClientState , glGetPointerv , glLogicOp , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev , glNormal and glDisableClientState
constant GL.GL_NORMALIZE
Used in glIsEnabled , glGetIntegerv , glDisable , glPopAttrib , glEnable , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev and glNormal
constant GL.GL_NORMAL_ARRAY
Used in glIsEnabled , glGetIntegerv , glNormalPointer , glEnableClientState , glGetPointerv , glGetBooleanv , glGetFloatv , glGetDoublev and glDisableClientState
constant GL.GL_NORMAL_ARRAY_POINTER
Used in glGetPointerv
constant GL.GL_NORMAL_ARRAY_STRIDE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_NORMAL_ARRAY_TYPE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_NOTEQUAL
Used in glAlphaFunc , glDepthFunc and glStencilFunc
constant GL.GL_NO_ERROR
Used in glGetError
constant GL.GL_OBJECT_LINEAR
Used in glTexGen
constant GL.GL_OBJECT_PLANE
Used in glGetTexGen and glTexGen
constant GL.GL_OCCLUSION_RESULT_HP
constant GL.GL_OCCLUSION_TEST_HP
constant GL.GL_ONE
Used in glGetIntegerv , glBlendFunc , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_ONE_MINUS_CONSTANT_ALPHA_EXT
constant GL.GL_ONE_MINUS_CONSTANT_COLOR_EXT
constant GL.GL_ONE_MINUS_DST_ALPHA
Used in glBlendFunc
constant GL.GL_ONE_MINUS_DST_COLOR
Used in glBlendFunc
constant GL.GL_ONE_MINUS_SRC_ALPHA
Used in glBlendFunc
constant GL.GL_ONE_MINUS_SRC_COLOR
Used in glBlendFunc
constant GL.GL_OR
Used in glLogicOp and glGetMap
constant GL.GL_ORDER
Used in glGetMap
constant GL.GL_OR_INVERTED
Used in glLogicOp
constant GL.GL_OR_REVERSE
Used in glLogicOp
constant GL.GL_OUT_OF_MEMORY
Used in glGetError , glNewList and glEndList
constant GL.GL_PACK_ALIGNMENT
Used in glPixelStore , glGetIntegerv , glGetBooleanv , glGetTexImage , glGetFloatv and glGetDoublev
constant GL.GL_PACK_IMAGE_HEIGHT_EXT
constant GL.GL_PACK_LSB_FIRST
Used in glPixelStore , glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev and glReadPixels
constant GL.GL_PACK_ROW_LENGTH
Used in glPixelStore , glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_PACK_SKIP_IMAGES_EXT
constant GL.GL_PACK_SKIP_PIXELS
Used in glPixelStore , glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_PACK_SKIP_ROWS
Used in glPixelStore , glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_PACK_SWAP_BYTES
Used in glPixelStore , glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev and glReadPixels
constant GL.GL_PASS_THROUGH_TOKEN
Used in glPassThrough and glFeedbackBuffer
constant GL.GL_PERSPECTIVE_CORRECTION_HINT
Used in glGetIntegerv , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev and glHint
constant GL.GL_PIXEL_CUBIC_WEIGHT_EXT
constant GL.GL_PIXEL_MAG_FILTER_EXT
constant GL.GL_PIXEL_MAP_A_TO_A
Used in glGetIntegerv , glGetPixelMap , glPixelTransfer , glGetBooleanv , glPixelMap , glGetFloatv and glGetDoublev
constant GL.GL_PIXEL_MAP_A_TO_A_SIZE
Used in glGetIntegerv , glPixelTransfer , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_PIXEL_MAP_B_TO_B
Used in glGetIntegerv , glGetPixelMap , glPixelTransfer , glGetBooleanv , glPixelMap , glGetFloatv and glGetDoublev
constant GL.GL_PIXEL_MAP_B_TO_B_SIZE
Used in glGetIntegerv , glPixelTransfer , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_PIXEL_MAP_G_TO_G
Used in glGetIntegerv , glGetPixelMap , glPixelTransfer , glGetBooleanv , glPixelMap , glGetFloatv and glGetDoublev
constant GL.GL_PIXEL_MAP_G_TO_G_SIZE
Used in glGetIntegerv , glPixelTransfer , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_PIXEL_MAP_I_TO_A
Used in glGetIntegerv , glDrawPixels , glGetPixelMap , glPixelTransfer , glGetBooleanv , glPixelMap , glGetFloatv , glGetDoublev , glReadPixels , glTexImage2D and glTexImage1D
constant GL.GL_PIXEL_MAP_I_TO_A_SIZE
Used in glGetIntegerv , glPixelTransfer , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_PIXEL_MAP_I_TO_B
Used in glGetIntegerv , glDrawPixels , glGetPixelMap , glPixelTransfer , glGetBooleanv , glPixelMap , glGetFloatv , glGetDoublev , glReadPixels , glTexImage2D and glTexImage1D
constant GL.GL_PIXEL_MAP_I_TO_B_SIZE
Used in glGetIntegerv , glPixelTransfer , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_PIXEL_MAP_I_TO_G
Used in glGetIntegerv , glDrawPixels , glGetPixelMap , glPixelTransfer , glGetBooleanv , glPixelMap , glGetFloatv , glGetDoublev , glReadPixels , glTexImage2D and glTexImage1D
constant GL.GL_PIXEL_MAP_I_TO_G_SIZE
Used in glGetIntegerv , glPixelTransfer , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_PIXEL_MAP_I_TO_I
Used in glGetIntegerv , glDrawPixels , glGetPixelMap , glPixelTransfer , glGetBooleanv , glPixelMap , glGetFloatv , glGetDoublev , glReadPixels and glCopyPixels
constant GL.GL_PIXEL_MAP_I_TO_I_SIZE
Used in glGetIntegerv , glPixelTransfer , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_PIXEL_MAP_I_TO_R
Used in glGetIntegerv , glDrawPixels , glGetPixelMap , glPixelTransfer , glGetBooleanv , glPixelMap , glGetFloatv , glGetDoublev , glReadPixels , glTexImage2D and glTexImage1D
constant GL.GL_PIXEL_MAP_I_TO_R_SIZE
Used in glGetIntegerv , glPixelTransfer , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_PIXEL_MAP_R_TO_R
Used in glGetIntegerv , glGetPixelMap , glPixelTransfer , glGetBooleanv , glPixelMap , glGetFloatv and glGetDoublev
constant GL.GL_PIXEL_MAP_R_TO_R_SIZE
Used in glGetIntegerv , glPixelTransfer , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_PIXEL_MAP_S_TO_S
Used in glGetIntegerv , glDrawPixels , glGetPixelMap , glPixelTransfer , glGetBooleanv , glPixelMap , glGetFloatv , glGetDoublev , glReadPixels and glCopyPixels
constant GL.GL_PIXEL_MAP_S_TO_S_SIZE
Used in glGetIntegerv , glPixelTransfer , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_PIXEL_MIN_FILTER_EXT
constant GL.GL_PIXEL_MODE_BIT
Used in glPopAttrib and glPushAttrib
constant GL.GL_PIXEL_TRANSFORM_2D_EXT
constant GL.GL_PIXEL_TRANSFORM_2D_MATRIX_EXT
constant GL.GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT
constant GL.GL_PIXEL_TRANSFORM_COLOR_TABLE_EXT
constant GL.GL_POINT
Used in glIsEnabled , glGetIntegerv , glEnd , glDrawElements , glDrawArrays , glDisable , glEdgeFlag , glPopAttrib , glEnable , glPolygonMode , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev , glFeedbackBuffer , glBegin , glHint , glEdgeFlagv , glPointSize and glEvalMesh
constant GL.GL_POINTS
Used in glEnd , glDrawElements , glDrawArrays , glBegin and glEvalMesh
constant GL.GL_POINT_BIT
Used in glPopAttrib and glPushAttrib
constant GL.GL_POINT_SIZE
Used in glGetIntegerv , glPolygonMode , glGetBooleanv , glGetFloatv , glGetDoublev and glPointSize
constant GL.GL_POINT_SIZE_GRANULARITY
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev and glPointSize
constant GL.GL_POINT_SIZE_RANGE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev and glPointSize
constant GL.GL_POINT_SMOOTH
Used in glIsEnabled , glGetIntegerv , glDisable , glPopAttrib , glEnable , glPolygonMode , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev , glHint and glPointSize
constant GL.GL_POINT_SMOOTH_HINT
Used in glGetIntegerv , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev and glHint
constant GL.GL_POINT_TOKEN
Used in glFeedbackBuffer
constant GL.GL_POLYGON
Used in glPolygonOffset , glIsEnabled , glGetIntegerv , glEnd , glDrawElements , glDrawArrays , glDisable , glEdgeFlag , glPopAttrib , glEnable , glPolygonMode , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev , glRect , glFeedbackBuffer , glBegin , glHint , glEdgeFlagv and glPolygonStipple
constant GL.GL_POLYGON_BIT
Used in glPopAttrib and glPushAttrib
constant GL.GL_POLYGON_MODE
Used in glGetIntegerv , glEdgeFlag , glPopAttrib , glPolygonMode , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev and glEdgeFlagv
constant GL.GL_POLYGON_OFFSET_FACTOR
Used in glGetIntegerv , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_POLYGON_OFFSET_FILL
Used in glIsEnabled , glGetIntegerv , glDisable , glPopAttrib , glEnable , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_POLYGON_OFFSET_LINE
Used in glIsEnabled , glGetIntegerv , glDisable , glPopAttrib , glEnable , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_POLYGON_OFFSET_POINT
Used in glIsEnabled , glGetIntegerv , glDisable , glPopAttrib , glEnable , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_POLYGON_OFFSET_UNITS
Used in glGetIntegerv , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_POLYGON_SMOOTH
Used in glIsEnabled , glGetIntegerv , glDisable , glPopAttrib , glEnable , glPolygonMode , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev and glHint
constant GL.GL_POLYGON_SMOOTH_HINT
Used in glGetIntegerv , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev and glHint
constant GL.GL_POLYGON_STIPPLE
Used in glIsEnabled , glGetIntegerv , glDisable , glPopAttrib , glEnable , glPolygonMode , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev and glPolygonStipple
constant GL.GL_POLYGON_STIPPLE_BIT
Used in glPopAttrib and glPushAttrib
constant GL.GL_POLYGON_TOKEN
Used in glFeedbackBuffer
constant GL.GL_POSITION
Used in glGetLight and glLight
constant GL.GL_POST_CONVOLUTION_ALPHA_BIAS_EXT
constant GL.GL_POST_CONVOLUTION_ALPHA_SCALE_EXT
constant GL.GL_POST_CONVOLUTION_BLUE_BIAS_EXT
constant GL.GL_POST_CONVOLUTION_BLUE_SCALE_EXT
constant GL.GL_POST_CONVOLUTION_COLOR_TABLE_SGI
constant GL.GL_POST_CONVOLUTION_GREEN_BIAS_EXT
constant GL.GL_POST_CONVOLUTION_GREEN_SCALE_EXT
constant GL.GL_POST_CONVOLUTION_RED_BIAS_EXT
constant GL.GL_POST_CONVOLUTION_RED_SCALE_EXT
constant GL.GL_PROJECTION
Used in glPushMatrix , glMatrixMode , glFrustum , glGetIntegerv , glGetBooleanv , glTranslate , glGetFloatv , glGetDoublev , glRotate , glScale , glOrtho and glPopMatrix
constant GL.GL_PROJECTION_MATRIX
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_PROJECTION_STACK_DEPTH
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_PROXY_COLOR_TABLE_SGI
constant GL.GL_PROXY_HISTOGRAM_EXT
constant GL.GL_PROXY_PIXEL_TRANSFORM_COLOR_TABLE_EXT
constant GL.GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI
constant GL.GL_PROXY_TEXTURE_1D
Used in glGetTexLevelParameter , glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev , glNewList , glEndList and glTexImage1D
constant GL.GL_PROXY_TEXTURE_2D
Used in glGetTexLevelParameter , glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev , glNewList , glTexImage2D and glEndList
constant GL.GL_PROXY_TEXTURE_3D_EXT
constant GL.GL_PROXY_TEXTURE_COLOR_TABLE_SGI
constant GL.GL_Q
Used in glGetTexGen , glEnd , glDrawElements , glDrawArrays , glGetLight , glBegin , glLight , glEvalMesh and glTexGen
constant GL.GL_QUADRATIC_ATTENUATION
Used in glGetLight and glLight
constant GL.GL_QUADS
Used in glEnd , glDrawElements , glDrawArrays and glBegin
constant GL.GL_QUAD_STRIP
Used in glEnd , glDrawElements , glDrawArrays , glBegin and glEvalMesh
constant GL.GL_R
Used in glPixelStore , glTexEnv , glRenderMode , glGetTexGen , glGetIntegerv , glCopyTexSubImage2D , glDrawPixels , glCopyTexImage1D , glTexSubImage2D , glPopAttrib , glPixelTransfer , glGetTexParameter , glGetBooleanv , glGetTexImage , glPushAttrib , glGetFloatv , glAccum , glReadBuffer , glGetDoublev , glReadPixels , glCopyTexImage2D , glTexImage2D , glStencilOp , glGetString , glTexParameter , glTexSubImage1D , glDrawBuffer , glTexImage1D , glCopyTexSubImage1D and glTexGen
constant GL.GL_R3_G3_B2
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_READ_BUFFER
Used in glGetIntegerv , glCopyTexSubImage2D , glCopyTexImage1D , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev , glCopyTexImage2D and glCopyTexSubImage1D
constant GL.GL_RED
Used in glGetIntegerv , glDrawPixels , glTexSubImage2D , glPopAttrib , glPixelTransfer , glGetBooleanv , glGetTexImage , glPushAttrib , glGetFloatv , glGetDoublev , glReadPixels , glTexImage2D , glTexSubImage1D and glTexImage1D
constant GL.GL_REDUCE_EXT
constant GL.GL_RED_BIAS
Used in glGetIntegerv , glPopAttrib , glPixelTransfer , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_RED_BITS
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_RED_SCALE
Used in glGetIntegerv , glPopAttrib , glPixelTransfer , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_RENDER
Used in glRenderMode , glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev and glGetString
constant GL.GL_RENDERER
Used in glGetString
constant GL.GL_RENDER_MODE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_REPEAT
Used in glGetTexParameter and glTexParameter
constant GL.GL_REPLACE
Used in glTexEnv and glStencilOp
constant GL.GL_REPLICATE_BORDER_HP
constant GL.GL_RESCALE_NORMAL_EXT
constant GL.GL_RETURN
Used in glAccum
constant GL.GL_RGB
Used in glPixelStore , glTexEnv , glGetIntegerv , glDrawPixels , glCopyTexImage1D , glTexSubImage2D , glGetBooleanv , glGetTexImage , glGetFloatv , glGetDoublev , glReadPixels , glCopyTexImage2D , glTexImage2D , glTexSubImage1D and glTexImage1D
constant GL.GL_RGB10
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_RGB10_A2
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_RGB12
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_RGB16
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_RGB4
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_RGB5
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_RGB5_A1
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_RGB8
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_RGBA
Used in glTexEnv , glGetIntegerv , glDrawPixels , glCopyTexImage1D , glTexSubImage2D , glGetBooleanv , glGetTexImage , glGetFloatv , glGetDoublev , glReadPixels , glCopyTexImage2D , glTexImage2D , glTexSubImage1D and glTexImage1D
constant GL.GL_RGBA12
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_RGBA16
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_RGBA2
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_RGBA4
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_RGBA8
Used in glCopyTexImage1D , glCopyTexImage2D , glTexImage2D and glTexImage1D
constant GL.GL_RGBA_MODE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_RIGHT
Used in glReadBuffer and glDrawBuffer
constant GL.GL_S
Used in glPushMatrix , glLoadName , glIsEnabled , glPushName , glRenderMode , glGetTexGen , glGetIntegerv , glColorMaterial , glGetError , glDrawPixels , glBlendFunc , glVertexPointer , glSelectBuffer , glGetLight , glInitNames , glDisable , glColorPointer , glTexSubImage2D , glNormalPointer , glPopAttrib , glEnable , glGetPointerv , glPopName , glLogicOp , glGetBooleanv , glGetTexImage , glPushAttrib , glGetFloatv , glMaterial , glGetDoublev , glCallLists , glShadeModel , glReadPixels , glTexImage2D , glLight , glPopClientAttrib , glStencilOp , glTexCoordPointer , glCopyPixels , glIndexPointer , glPushClientAttrib , glScissor , glTexSubImage1D , glTexImage1D , glStencilFunc , glGetMaterial , glClear , glPopMatrix and glTexGen
constant GL.GL_SCISSOR_BIT
Used in glPopAttrib and glPushAttrib
constant GL.GL_SCISSOR_BOX
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_SCISSOR_TEST
Used in glIsEnabled , glGetIntegerv , glDisable , glPopAttrib , glEnable , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev and glScissor
constant GL.GL_SELECT
Used in glLoadName , glPushName , glRenderMode , glSelectBuffer , glInitNames , glGetPointerv and glPopName
constant GL.GL_SELECTION_BUFFER_POINTER
Used in glGetPointerv
constant GL.GL_SELECTION_BUFFER_SIZE
constant GL.GL_SEPARABLE_2D_EXT
constant GL.GL_SET
Used in glLogicOp
constant GL.GL_SGI_color_table
constant GL.GL_SGI_texture_color_table
constant GL.GL_SHADE_MODEL
Used in glGetIntegerv , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_SHININESS
Used in glMaterial and glGetMaterial
constant GL.GL_SHORT
Used in glDrawPixels , glVertexPointer , glColorPointer , glTexSubImage2D , glNormalPointer , glGetTexImage , glCallLists , glReadPixels , glTexImage2D , glTexCoordPointer , glIndexPointer , glTexSubImage1D and glTexImage1D
constant GL.GL_SMOOTH
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev and glShadeModel
constant GL.GL_SPECULAR
Used in glColorMaterial , glGetLight , glMaterial , glLight and glGetMaterial
constant GL.GL_SPHERE_MAP
Used in glTexGen
constant GL.GL_SPOT_CUTOFF
Used in glGetLight and glLight
constant GL.GL_SPOT_DIRECTION
Used in glGetLight and glLight
constant GL.GL_SPOT_EXPONENT
Used in glGetLight and glLight
constant GL.GL_SRC_ALPHA
Used in glBlendFunc
constant GL.GL_SRC_ALPHA_SATURATE
Used in glBlendFunc
constant GL.GL_SRC_COLOR
Used in glBlendFunc
constant GL.GL_STACK_OVERFLOW
Used in glPushMatrix , glPushName , glGetError , glPopAttrib , glPopName , glPushAttrib , glPopClientAttrib , glPushClientAttrib and glPopMatrix
constant GL.GL_STACK_UNDERFLOW
Used in glPushMatrix , glPushName , glGetError , glPopAttrib , glPopName , glPushAttrib , glPopClientAttrib , glPushClientAttrib and glPopMatrix
constant GL.GL_STENCIL
Used in glIsEnabled , glGetIntegerv , glDrawPixels , glDisable , glPopAttrib , glEnable , glGetBooleanv , glGetTexImage , glPushAttrib , glGetFloatv , glGetDoublev , glReadPixels , glTexImage2D , glStencilOp , glCopyPixels , glTexImage1D , glStencilFunc and glClear
constant GL.GL_STENCIL_BITS
Used in glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev and glStencilOp
constant GL.GL_STENCIL_BUFFER_BIT
Used in glPopAttrib , glPushAttrib and glClear
constant GL.GL_STENCIL_CLEAR_VALUE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_STENCIL_FAIL
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_STENCIL_FUNC
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_STENCIL_INDEX
Used in glDrawPixels , glGetTexImage , glReadPixels , glTexImage2D and glTexImage1D
constant GL.GL_STENCIL_PASS_DEPTH_FAIL
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_STENCIL_PASS_DEPTH_PASS
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_STENCIL_REF
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_STENCIL_TEST
Used in glIsEnabled , glGetIntegerv , glDisable , glPopAttrib , glEnable , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev , glStencilOp and glStencilFunc
constant GL.GL_STENCIL_VALUE_MASK
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_STENCIL_WRITEMASK
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_STEREO
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_SUBPIXEL_BITS
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_SUNX_geometry_compression
constant GL.GL_SUNX_surface_hint
constant GL.GL_SUN_convolution_border_modes
constant GL.GL_SUN_multi_draw_arrays
constant GL.GL_SURFACE_SIZE_HINT_SUNX
constant GL.GL_T
Used in glPushMatrix , glMatrixMode , glIsEnabled , glGetTexLevelParameter , glTexEnv , glIsList , glAreTexturesResident , glGetTexGen , glGetIntegerv , glEnd , glIsTexture , glDrawElements , glDrawArrays , glCopyTexSubImage2D , glBindTexture , glDisable , glCopyTexImage1D , glTexSubImage2D , glEdgeFlag , glPopAttrib , glEnable , glColorMask , glEnableClientState , glGetPointerv , glGetTexParameter , glGetBooleanv , glGetTexImage , glPushAttrib , glGetFloatv , glGetDoublev , glInterleavedArrays , glReadPixels , glCopyTexImage2D , glTexImage2D , glGetTexEnv , glBegin , glTexCoordPointer , glTexParameter , glDisableClientState , glTexSubImage1D , glEdgeFlagv , glTexImage1D , glCopyTexSubImage1D , glPopMatrix and glTexGen
constant GL.GL_T2F_C3F_V3F
Used in glInterleavedArrays
constant GL.GL_T2F_C4F_N3F_V3F
Used in glInterleavedArrays
constant GL.GL_T2F_C4UB_V3F
Used in glInterleavedArrays
constant GL.GL_T2F_N3F_V3F
Used in glInterleavedArrays
constant GL.GL_T2F_V3F
Used in glInterleavedArrays
constant GL.GL_T4F_C4F_N3F_V4F
Used in glInterleavedArrays
constant GL.GL_T4F_V4F
Used in glInterleavedArrays
constant GL.GL_TABLE_TOO_LARGE_EXT
constant GL.GL_TEXTURE
Used in glPushMatrix , glMatrixMode , glIsEnabled , glGetTexLevelParameter , glTexEnv , glAreTexturesResident , glGetTexGen , glGetIntegerv , glCopyTexSubImage2D , glBindTexture , glDisable , glCopyTexImage1D , glTexSubImage2D , glPopAttrib , glEnable , glEnableClientState , glGetPointerv , glGetTexParameter , glGetBooleanv , glGetTexImage , glPushAttrib , glGetFloatv , glGetDoublev , glCopyTexImage2D , glTexImage2D , glGetTexEnv , glTexCoordPointer , glTexParameter , glDisableClientState , glTexSubImage1D , glTexImage1D , glCopyTexSubImage1D , glPopMatrix and glTexGen
constant GL.GL_TEXTURE_1D
Used in glIsEnabled , glGetTexLevelParameter , glGetIntegerv , glBindTexture , glDisable , glCopyTexImage1D , glPopAttrib , glEnable , glGetTexParameter , glGetBooleanv , glGetTexImage , glPushAttrib , glGetFloatv , glGetDoublev , glTexParameter , glTexSubImage1D , glTexImage1D and glCopyTexSubImage1D
constant GL.GL_TEXTURE_2D
Used in glIsEnabled , glGetTexLevelParameter , glGetIntegerv , glCopyTexSubImage2D , glBindTexture , glDisable , glTexSubImage2D , glPopAttrib , glEnable , glGetTexParameter , glGetBooleanv , glGetTexImage , glPushAttrib , glGetFloatv , glGetDoublev , glCopyTexImage2D , glTexImage2D and glTexParameter
constant GL.GL_TEXTURE_3D_EXT
constant GL.GL_TEXTURE_ALPHA_SIZE
Used in glGetTexLevelParameter
constant GL.GL_TEXTURE_BINDING_1D
constant GL.GL_TEXTURE_BINDING_2D
constant GL.GL_TEXTURE_BIT
Used in glPopAttrib and glPushAttrib
constant GL.GL_TEXTURE_BLUE_SIZE
Used in glGetTexLevelParameter
constant GL.GL_TEXTURE_BORDER
Used in glGetTexLevelParameter , glCopyTexSubImage2D , glGetTexParameter , glTexParameter , glTexSubImage1D and glCopyTexSubImage1D
constant GL.GL_TEXTURE_BORDER_COLOR
Used in glGetTexParameter and glTexParameter
constant GL.GL_TEXTURE_COLOR_TABLE_SGI
constant GL.GL_TEXTURE_COMPONENTS
constant GL.GL_TEXTURE_COORD_ARRAY
Used in glIsEnabled , glGetIntegerv , glEnableClientState , glGetPointerv , glGetBooleanv , glGetFloatv , glGetDoublev , glTexCoordPointer and glDisableClientState
constant GL.GL_TEXTURE_COORD_ARRAY_POINTER
Used in glGetPointerv
constant GL.GL_TEXTURE_COORD_ARRAY_SIZE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_TEXTURE_COORD_ARRAY_STRIDE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_TEXTURE_COORD_ARRAY_TYPE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_TEXTURE_DEPTH_EXT
constant GL.GL_TEXTURE_ENV
Used in glTexEnv and glGetTexEnv
constant GL.GL_TEXTURE_ENV_COLOR
Used in glTexEnv and glGetTexEnv
constant GL.GL_TEXTURE_ENV_MODE
Used in glTexEnv and glGetTexEnv
constant GL.GL_TEXTURE_GEN_MODE
Used in glGetTexGen , glPopAttrib , glPushAttrib and glTexGen
constant GL.GL_TEXTURE_GEN_Q
Used in glIsEnabled , glGetIntegerv , glDisable , glEnable , glGetBooleanv , glGetFloatv , glGetDoublev and glTexGen
constant GL.GL_TEXTURE_GEN_R
Used in glIsEnabled , glGetIntegerv , glDisable , glEnable , glGetBooleanv , glGetFloatv , glGetDoublev and glTexGen
constant GL.GL_TEXTURE_GEN_S
Used in glIsEnabled , glGetIntegerv , glDisable , glEnable , glGetBooleanv , glGetFloatv , glGetDoublev and glTexGen
constant GL.GL_TEXTURE_GEN_T
Used in glIsEnabled , glGetIntegerv , glDisable , glEnable , glGetBooleanv , glGetFloatv , glGetDoublev and glTexGen
constant GL.GL_TEXTURE_GREEN_SIZE
Used in glGetTexLevelParameter
constant GL.GL_TEXTURE_HEIGHT
Used in glGetTexLevelParameter , glCopyTexSubImage2D and glTexSubImage2D
constant GL.GL_TEXTURE_INTENSITY_SIZE
Used in glGetTexLevelParameter
constant GL.GL_TEXTURE_INTERNAL_FORMAT
Used in glGetTexLevelParameter
constant GL.GL_TEXTURE_LUMINANCE_SIZE
Used in glGetTexLevelParameter
constant GL.GL_TEXTURE_MAG_FILTER
Used in glGetTexParameter and glTexParameter
constant GL.GL_TEXTURE_MATRIX
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_TEXTURE_MIN_FILTER
Used in glGetTexParameter and glTexParameter
constant GL.GL_TEXTURE_PRIORITY
Used in glGetTexParameter and glTexParameter
constant GL.GL_TEXTURE_RED_SIZE
Used in glGetTexLevelParameter
constant GL.GL_TEXTURE_RESIDENT
Used in glAreTexturesResident and glGetTexParameter
constant GL.GL_TEXTURE_STACK_DEPTH
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_TEXTURE_WIDTH
Used in glGetTexLevelParameter , glCopyTexSubImage2D , glTexSubImage2D , glTexSubImage1D and glCopyTexSubImage1D
constant GL.GL_TEXTURE_WRAP_R_EXT
constant GL.GL_TEXTURE_WRAP_S
Used in glGetTexParameter and glTexParameter
constant GL.GL_TEXTURE_WRAP_T
Used in glGetTexParameter and glTexParameter
constant GL.GL_TRANSFORM_BIT
Used in glPopAttrib and glPushAttrib
constant GL.GL_TRIANGLES
Used in glEnd , glDrawElements , glDrawArrays and glBegin
constant GL.GL_TRIANGLE_FAN
Used in glEnd , glDrawElements , glDrawArrays and glBegin
constant GL.GL_TRIANGLE_STRIP
Used in glEnd , glDrawElements , glDrawArrays and glBegin
constant GL.GL_TRUE
Used in glIsEnabled , glIsList , glAreTexturesResident , glGetIntegerv , glIsTexture , glDisable , glEdgeFlag , glEnable , glColorMask , glGetTexParameter , glGetBooleanv , glGetFloatv , glGetDoublev , glReadPixels and glEdgeFlagv
constant GL.GL_UNPACK_ALIGNMENT
Used in glPixelStore , glGetIntegerv , glDrawPixels , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_UNPACK_IMAGE_HEIGHT_EXT
constant GL.GL_UNPACK_LSB_FIRST
Used in glPixelStore , glGetIntegerv , glDrawPixels , glGetBooleanv , glGetFloatv , glGetDoublev , glTexImage2D , glTexImage1D and glPolygonStipple
constant GL.GL_UNPACK_ROW_LENGTH
Used in glPixelStore , glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_UNPACK_SKIP_IMAGES_EXT
constant GL.GL_UNPACK_SKIP_PIXELS
Used in glPixelStore , glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_UNPACK_SKIP_ROWS
Used in glPixelStore , glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_UNPACK_SWAP_BYTES
Used in glPixelStore , glGetIntegerv , glGetBooleanv , glGetFloatv , glGetDoublev and glPolygonStipple
constant GL.GL_UNSIGNED_BYTE
Used in glDrawElements , glDrawPixels , glColorPointer , glTexSubImage2D , glGetTexImage , glCallLists , glReadPixels , glTexImage2D , glIndexPointer , glTexSubImage1D and glTexImage1D
constant GL.GL_UNSIGNED_INT
Used in glDrawElements , glDrawPixels , glColorPointer , glTexSubImage2D , glGetTexImage , glCallLists , glReadPixels , glTexImage2D , glTexSubImage1D and glTexImage1D
constant GL.GL_UNSIGNED_INT_8_8_8_8
constant GL.GL_UNSIGNED_INT_8_8_8_8_REV
constant GL.GL_UNSIGNED_SHORT
Used in glDrawElements , glDrawPixels , glColorPointer , glTexSubImage2D , glGetTexImage , glCallLists , glReadPixels , glTexImage2D , glTexSubImage1D and glTexImage1D
constant GL.GL_V2F
Used in glInterleavedArrays
constant GL.GL_V3F
Used in glInterleavedArrays
constant GL.GL_VENDOR
Used in glGetString
constant GL.GL_VERSION
Used in glGetString
constant GL.GL_VERSION_1_1
constant GL.GL_VERTEX_ARRAY
Used in glIsEnabled , glArrayElement , glGetIntegerv , glDrawElements , glDrawArrays , glVertexPointer , glEnableClientState , glGetPointerv , glGetBooleanv , glGetFloatv , glGetDoublev and glDisableClientState
constant GL.GL_VERTEX_ARRAY_POINTER
Used in glGetPointerv
constant GL.GL_VERTEX_ARRAY_SIZE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_VERTEX_ARRAY_STRIDE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_VERTEX_ARRAY_TYPE
Used in glGetIntegerv , glGetBooleanv , glGetFloatv and glGetDoublev
constant GL.GL_VIEWPORT
Used in glGetIntegerv , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv and glGetDoublev
constant GL.GL_VIEWPORT_BIT
Used in glPopAttrib and glPushAttrib
constant GL.GL_WRAP_BORDER_SUN
constant GL.GL_XOR
Used in glLogicOp
constant GL.GL_ZERO
Used in glGetIntegerv , glBlendFunc , glGetBooleanv , glGetFloatv , glGetDoublev and glStencilOp
constant GL.GL_ZOOM_X
Used in glGetIntegerv , glDrawPixels , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev and glCopyPixels
constant GL.GL_ZOOM_Y
Used in glGetIntegerv , glDrawPixels , glPopAttrib , glGetBooleanv , glPushAttrib , glGetFloatv , glGetDoublev and glCopyPixels
| Module GTK2 |
constant GTK2.FALSE
constant GTK2.GDK_2BUTTON_PRESS
constant GTK2.GDK_3BUTTON_PRESS
constant GTK2.GDK_ACTION_ASK
constant GTK2.GDK_ACTION_COPY
constant GTK2.GDK_ACTION_DEFAULT
constant GTK2.GDK_ACTION_LINK
constant GTK2.GDK_ACTION_MOVE
constant GTK2.GDK_ACTION_PRIVATE
constant GTK2.GDK_ALL_EVENTS_MASK
constant GTK2.GDK_AND
constant GTK2.GDK_AND_INVERT
constant GTK2.GDK_AND_REVERSE
constant GTK2.GDK_ARROW
constant GTK2.GDK_AXIS_IGNORE
constant GTK2.GDK_AXIS_LAST
constant GTK2.GDK_AXIS_PRESSURE
constant GTK2.GDK_AXIS_WHEEL
constant GTK2.GDK_AXIS_X
constant GTK2.GDK_AXIS_XTILT
constant GTK2.GDK_AXIS_Y
constant GTK2.GDK_AXIS_YTILT
constant GTK2.GDK_BASED_ARROW_DOWN
constant GTK2.GDK_BASED_ARROW_UP
constant GTK2.GDK_BOAT
constant GTK2.GDK_BOGOSITY
constant GTK2.GDK_BOTTOM_LEFT_CORNER
constant GTK2.GDK_BOTTOM_RIGHT_CORNER
constant GTK2.GDK_BOTTOM_SIDE
constant GTK2.GDK_BOTTOM_TEE
constant GTK2.GDK_BOX_SPIRAL
constant GTK2.GDK_BUTTON1_MASK
constant GTK2.GDK_BUTTON1_MOTION_MASK
constant GTK2.GDK_BUTTON2_MASK
constant GTK2.GDK_BUTTON2_MOTION_MASK
constant GTK2.GDK_BUTTON3_MASK
constant GTK2.GDK_BUTTON3_MOTION_MASK
constant GTK2.GDK_BUTTON4_MASK
constant GTK2.GDK_BUTTON5_MASK
constant GTK2.GDK_BUTTON_MOTION_MASK
constant GTK2.GDK_BUTTON_PRESS
constant GTK2.GDK_BUTTON_PRESS_MASK
constant GTK2.GDK_BUTTON_RELEASE
constant GTK2.GDK_BUTTON_RELEASE_MASK
constant GTK2.GDK_CAP_BUTT
constant GTK2.GDK_CAP_NOT_LAST
constant GTK2.GDK_CAP_PROJECTING
constant GTK2.GDK_CAP_ROUND
constant GTK2.GDK_CENTER_PTR
constant GTK2.GDK_CIRCLE
constant GTK2.GDK_CLEAR
constant GTK2.GDK_CLIENT_EVENT
constant GTK2.GDK_CLIP_BY_CHILDREN
constant GTK2.GDK_CLOCK
constant GTK2.GDK_COFFEE_MUG
constant GTK2.GDK_COLORSPACE_RGB
constant GTK2.GDK_CONFIGURE
constant GTK2.GDK_CONTROL_MASK
constant GTK2.GDK_COPY
constant GTK2.GDK_COPY_INVERT
constant GTK2.GDK_CROSS
constant GTK2.GDK_CROSSHAIR
constant GTK2.GDK_CROSSING_GRAB
constant GTK2.GDK_CROSSING_NORMAL
constant GTK2.GDK_CROSSING_UNGRAB
constant GTK2.GDK_CROSS_REVERSE
constant GTK2.GDK_CURSOR_IS_PIXMAP
constant GTK2.GDK_DECOR_ALL
constant GTK2.GDK_DECOR_BORDER
constant GTK2.GDK_DECOR_MAXIMIZE
constant GTK2.GDK_DECOR_MENU
constant GTK2.GDK_DECOR_MINIMIZE
constant GTK2.GDK_DECOR_RESIZEH
constant GTK2.GDK_DECOR_TITLE
constant GTK2.GDK_DELETE
constant GTK2.GDK_DESTROY
constant GTK2.GDK_DIAMOND_CROSS
constant GTK2.GDK_DOT
constant GTK2.GDK_DOTBOX
constant GTK2.GDK_DOUBLE_ARROW
constant GTK2.GDK_DRAFT_LARGE
constant GTK2.GDK_DRAFT_SMALL
constant GTK2.GDK_DRAG_ENTER
constant GTK2.GDK_DRAG_LEAVE
constant GTK2.GDK_DRAG_MOTION
constant GTK2.GDK_DRAG_PROTO_LOCAL
constant GTK2.GDK_DRAG_PROTO_MOTIF
constant GTK2.GDK_DRAG_PROTO_NONE
constant GTK2.GDK_DRAG_PROTO_OLE2
constant GTK2.GDK_DRAG_PROTO_ROOTWIN
constant GTK2.GDK_DRAG_PROTO_WIN32_DROPFILES
constant GTK2.GDK_DRAG_PROTO_XDND
constant GTK2.GDK_DRAG_STATUS
constant GTK2.GDK_DRAPED_BOX
constant GTK2.GDK_DROP_FINISHED
constant GTK2.GDK_DROP_START
constant GTK2.GDK_ENTER_NOTIFY
constant GTK2.GDK_ENTER_NOTIFY_MASK
constant GTK2.GDK_EQUIV
constant GTK2.GDK_EVEN_ODD_RULE
constant GTK2.GDK_EXCHANGE
constant GTK2.GDK_EXPOSE
constant GTK2.GDK_EXPOSURE_MASK
constant GTK2.GDK_EXTENSION_EVENTS_ALL
constant GTK2.GDK_EXTENSION_EVENTS_CURSOR
constant GTK2.GDK_EXTENSION_EVENTS_NONE
constant GTK2.GDK_FILTER_CONTINUE
constant GTK2.GDK_FILTER_REMOVE
constant GTK2.GDK_FILTER_TRANSLATE
constant GTK2.GDK_FLEUR
constant GTK2.GDK_FOCUS_CHANGE
constant GTK2.GDK_FOCUS_CHANGE_MASK
constant GTK2.GDK_FUNC_ALL
constant GTK2.GDK_FUNC_CLOSE
constant GTK2.GDK_FUNC_MAXIMIZE
constant GTK2.GDK_FUNC_MINIMIZE
constant GTK2.GDK_FUNC_MOVE
constant GTK2.GDK_FUNC_RESIZE
constant GTK2.GDK_GC_BACKGROUND
constant GTK2.GDK_GC_CAP_STYLE
constant GTK2.GDK_GC_CLIP_MASK
constant GTK2.GDK_GC_CLIP_X_ORIGIN
constant GTK2.GDK_GC_CLIP_Y_ORIGIN
constant GTK2.GDK_GC_EXPOSURES
constant GTK2.GDK_GC_FILL
constant GTK2.GDK_GC_FONT
constant GTK2.GDK_GC_FOREGROUND
constant GTK2.GDK_GC_FUNCTION
constant GTK2.GDK_GC_JOIN_STYLE
constant GTK2.GDK_GC_LINE_STYLE
constant GTK2.GDK_GC_LINE_WIDTH
constant GTK2.GDK_GC_STIPPLE
constant GTK2.GDK_GC_SUBWINDOW
constant GTK2.GDK_GC_TILE
constant GTK2.GDK_GC_TS_X_ORIGIN
constant GTK2.GDK_GC_TS_Y_ORIGIN
constant GTK2.GDK_GOBBLER
constant GTK2.GDK_GRAB_ALREADY_GRABBED
constant GTK2.GDK_GRAB_FROZEN
constant GTK2.GDK_GRAB_INVALID_TIME
constant GTK2.GDK_GRAB_NOT_VIEWABLE
constant GTK2.GDK_GRAB_SUCCESS
constant GTK2.GDK_GRAVITY_CENTER
constant GTK2.GDK_GRAVITY_EAST
constant GTK2.GDK_GRAVITY_NORTH
constant GTK2.GDK_GRAVITY_NORTH_EAST
constant GTK2.GDK_GRAVITY_NORTH_WEST
constant GTK2.GDK_GRAVITY_SOUTH
constant GTK2.GDK_GRAVITY_SOUTH_EAST
constant GTK2.GDK_GRAVITY_SOUTH_WEST
constant GTK2.GDK_GRAVITY_STATIC
constant GTK2.GDK_GRAVITY_WEST
constant GTK2.GDK_GUMBY
constant GTK2.GDK_HAND1
constant GTK2.GDK_HAND2
constant GTK2.GDK_HEART
constant GTK2.GDK_HINT_ASPECT
constant GTK2.GDK_HINT_BASE_SIZE
constant GTK2.GDK_HINT_MAX_SIZE
constant GTK2.GDK_HINT_MIN_SIZE
constant GTK2.GDK_HINT_POS
constant GTK2.GDK_HINT_RESIZE_INC
constant GTK2.GDK_HINT_USER_POS
constant GTK2.GDK_HINT_USER_SIZE
constant GTK2.GDK_ICON
constant GTK2.GDK_IMAGE_FASTEST
constant GTK2.GDK_IMAGE_NORMAL
constant GTK2.GDK_IMAGE_SHARED
constant GTK2.GDK_INCLUDE_INFERIORS
constant GTK2.GDK_INPUT_EXCEPTION
constant GTK2.GDK_INPUT_ONLY
constant GTK2.GDK_INPUT_OUTPUT
constant GTK2.GDK_INPUT_READ
constant GTK2.GDK_INPUT_WRITE
constant GTK2.GDK_INTERP_BILINEAR
constant GTK2.GDK_INTERP_HYPER
constant GTK2.GDK_INTERP_NEAREST
constant GTK2.GDK_INTERP_TILES
constant GTK2.GDK_INVERT
constant GTK2.GDK_IRON_CROSS
constant GTK2.GDK_JOIN_BEVEL
constant GTK2.GDK_JOIN_MITER
constant GTK2.GDK_JOIN_ROUND
constant GTK2.GDK_KEY_PRESS
constant GTK2.GDK_KEY_PRESS_MASK
constant GTK2.GDK_KEY_RELEASE
constant GTK2.GDK_KEY_RELEASE_MASK
constant GTK2.GDK_LAST_CURSOR
constant GTK2.GDK_LEAVE_NOTIFY
constant GTK2.GDK_LEAVE_NOTIFY_MASK
constant GTK2.GDK_LEFTBUTTON
constant GTK2.GDK_LEFT_PTR
constant GTK2.GDK_LEFT_SIDE
constant GTK2.GDK_LEFT_TEE
constant GTK2.GDK_LINE_DOUBLE_DASH
constant GTK2.GDK_LINE_ON_OFF_DASH
constant GTK2.GDK_LINE_SOLID
constant GTK2.GDK_LL_ANGLE
constant GTK2.GDK_LOCK_MASK
constant GTK2.GDK_LR_ANGLE
constant GTK2.GDK_LSB_FIRST
constant GTK2.GDK_MAN
constant GTK2.GDK_MAP
constant GTK2.GDK_MIDDLEBUTTON
constant GTK2.GDK_MOD1_MASK
constant GTK2.GDK_MOD2_MASK
constant GTK2.GDK_MOD3_MASK
constant GTK2.GDK_MOD4_MASK
constant GTK2.GDK_MOD5_MASK
constant GTK2.GDK_MODE_DISABLED
constant GTK2.GDK_MODE_SCREEN
constant GTK2.GDK_MODE_WINDOW
constant GTK2.GDK_MODIFIER_MASK
constant GTK2.GDK_MOTION_NOTIFY
constant GTK2.GDK_MOUSE
constant GTK2.GDK_MSB_FIRST
constant GTK2.GDK_NAND
constant GTK2.GDK_NOOP
constant GTK2.GDK_NOR
constant GTK2.GDK_NOTHING
constant GTK2.GDK_NOTIFY_ANCESTOR
constant GTK2.GDK_NOTIFY_INFERIOR
constant GTK2.GDK_NOTIFY_NONLINEAR
constant GTK2.GDK_NOTIFY_NONLINEAR_VIRTUAL
constant GTK2.GDK_NOTIFY_UNKNOWN
constant GTK2.GDK_NOTIFY_VIRTUAL
constant GTK2.GDK_NO_EXPOSE
constant GTK2.GDK_OPAQUE_STIPPLED
constant GTK2.GDK_OR
constant GTK2.GDK_OR_INVERT
constant GTK2.GDK_OR_REVERSE
constant GTK2.GDK_OVERLAP_RECTANGLE_IN
constant GTK2.GDK_OVERLAP_RECTANGLE_OUT
constant GTK2.GDK_OVERLAP_RECTANGLE_PART
constant GTK2.GDK_OWNER_CHANGE
constant GTK2.GDK_OWNER_CHANGE_CLOSE
constant GTK2.GDK_OWNER_CHANGE_DESTROY
constant GTK2.GDK_OWNER_CHANGE_NEW_OWNER
constant GTK2.GDK_PENCIL
constant GTK2.GDK_PIRATE
constant GTK2.GDK_PIXBUF_ALPHA_BILEVEL
constant GTK2.GDK_PIXBUF_ALPHA_FULL
constant GTK2.GDK_PIXBUF_ERROR_BAD_OPTION
constant GTK2.GDK_PIXBUF_ERROR_CORRUPT_IMAGE
constant GTK2.GDK_PIXBUF_ERROR_FAILED
constant GTK2.GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY
constant GTK2.GDK_PIXBUF_ERROR_UNKNOWN_TYPE
constant GTK2.GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION
constant GTK2.GDK_PIXBUF_ROTATE_CLOCKWISE
constant GTK2.GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE
constant GTK2.GDK_PIXBUF_ROTATE_NONE
constant GTK2.GDK_PIXBUF_ROTATE_UPSIDEDOWN
constant GTK2.GDK_PLUS
constant GTK2.GDK_POINTER_MOTION_HINT_MASK
constant GTK2.GDK_POINTER_MOTION_MASK
constant GTK2.GDK_PROPERTY_CHANGE_MASK
constant GTK2.GDK_PROPERTY_DELETE
constant GTK2.GDK_PROPERTY_NEW_VALUE
constant GTK2.GDK_PROPERTY_NOTIFY
constant GTK2.GDK_PROP_MODE_APPEND
constant GTK2.GDK_PROP_MODE_PREPEND
constant GTK2.GDK_PROP_MODE_REPLACE
constant GTK2.GDK_PROXIMITY_IN
constant GTK2.GDK_PROXIMITY_IN_MASK
constant GTK2.GDK_PROXIMITY_OUT
constant GTK2.GDK_PROXIMITY_OUT_MASK
constant GTK2.GDK_QUESTION_ARROW
constant GTK2.GDK_RELEASE_MASK
constant GTK2.GDK_RGB_DITHER_MAX
constant GTK2.GDK_RGB_DITHER_NONE
constant GTK2.GDK_RGB_DITHER_NORMAL
constant GTK2.GDK_RIGHTBUTTON
constant GTK2.GDK_RIGHT_PTR
constant GTK2.GDK_RIGHT_SIDE
constant GTK2.GDK_RIGHT_TEE
constant GTK2.GDK_RTL_LOGO
constant GTK2.GDK_SAILBOAT
constant GTK2.GDK_SB_DOWN_ARROW
constant GTK2.GDK_SB_H_DOUBLE_ARROW
constant GTK2.GDK_SB_LEFT_ARROW
constant GTK2.GDK_SB_RIGHT_ARROW
constant GTK2.GDK_SB_UP_ARROW
constant GTK2.GDK_SB_V_DOUBLE_ARROW
constant GTK2.GDK_SCROLL
constant GTK2.GDK_SCROLL_DOWN
constant GTK2.GDK_SCROLL_LEFT
constant GTK2.GDK_SCROLL_MASK
constant GTK2.GDK_SCROLL_RIGHT
constant GTK2.GDK_SCROLL_UP
constant GTK2.GDK_SELECTION_CLEAR
constant GTK2.GDK_SELECTION_NOTIFY
constant GTK2.GDK_SELECTION_REQUEST
constant GTK2.GDK_SET
constant GTK2.GDK_SETTING
constant GTK2.GDK_SETTING_ACTION_CHANGED
constant GTK2.GDK_SETTING_ACTION_DELETED
constant GTK2.GDK_SETTING_ACTION_NEW
constant GTK2.GDK_SHIFT_MASK
constant GTK2.GDK_SHUTTLE
constant GTK2.GDK_SIZING
constant GTK2.GDK_SOLID
constant GTK2.GDK_SOURCE_CURSOR
constant GTK2.GDK_SOURCE_ERASER
constant GTK2.GDK_SOURCE_MOUSE
constant GTK2.GDK_SOURCE_PEN
constant GTK2.GDK_SPIDER
constant GTK2.GDK_SPRAYCAN
constant GTK2.GDK_STAR
constant GTK2.GDK_STIPPLED
constant GTK2.GDK_STRUCTURE_MASK
constant GTK2.GDK_SUBSTRUCTURE_MASK
constant GTK2.GDK_TARGET
constant GTK2.GDK_TCROSS
constant GTK2.GDK_TILED
constant GTK2.GDK_TOP_LEFT_ARROW
constant GTK2.GDK_TOP_LEFT_CORNER
constant GTK2.GDK_TOP_RIGHT_CORNER
constant GTK2.GDK_TOP_SIDE
constant GTK2.GDK_TOP_TEE
constant GTK2.GDK_TREK
constant GTK2.GDK_UL_ANGLE
constant GTK2.GDK_UMBRELLA
constant GTK2.GDK_UNMAP
constant GTK2.GDK_UR_ANGLE
constant GTK2.GDK_VISIBILITY_FULLY_OBSCURED
constant GTK2.GDK_VISIBILITY_NOTIFY
constant GTK2.GDK_VISIBILITY_NOTIFY_MASK
constant GTK2.GDK_VISIBILITY_PARTIAL
constant GTK2.GDK_VISIBILITY_UNOBSCURED
constant GTK2.GDK_VISUAL_DIRECT_COLOR
constant GTK2.GDK_VISUAL_GRAYSCALE
constant GTK2.GDK_VISUAL_PSEUDO_COLOR
constant GTK2.GDK_VISUAL_STATIC_COLOR
constant GTK2.GDK_VISUAL_STATIC_GRAY
constant GTK2.GDK_VISUAL_TRUE_COLOR
constant GTK2.GDK_WATCH
constant GTK2.GDK_WA_COLORMAP
constant GTK2.GDK_WA_CURSOR
constant GTK2.GDK_WA_NOREDIR
constant GTK2.GDK_WA_TITLE
constant GTK2.GDK_WA_VISUAL
constant GTK2.GDK_WA_WMCLASS
constant GTK2.GDK_WA_X
constant GTK2.GDK_WA_Y
constant GTK2.GDK_WINDING_RULE
constant GTK2.GDK_WINDOW_CHILD
constant GTK2.GDK_WINDOW_DIALOG
constant GTK2.GDK_WINDOW_EDGE_EAST
constant GTK2.GDK_WINDOW_EDGE_NORTH
constant GTK2.GDK_WINDOW_EDGE_NORTH_EAST
constant GTK2.GDK_WINDOW_EDGE_NORTH_WEST
constant GTK2.GDK_WINDOW_EDGE_SOUTH
constant GTK2.GDK_WINDOW_EDGE_SOUTH_EAST
constant GTK2.GDK_WINDOW_EDGE_SOUTH_WEST
constant GTK2.GDK_WINDOW_EDGE_WEST
constant GTK2.GDK_WINDOW_FOREIGN
constant GTK2.GDK_WINDOW_ROOT
constant GTK2.GDK_WINDOW_STATE
constant GTK2.GDK_WINDOW_STATE_ABOVE
constant GTK2.GDK_WINDOW_STATE_BELOW
constant GTK2.GDK_WINDOW_STATE_FULLSCREEN
constant GTK2.GDK_WINDOW_STATE_ICONIFIED
constant GTK2.GDK_WINDOW_STATE_MAXIMIZED
constant GTK2.GDK_WINDOW_STATE_STICKY
constant GTK2.GDK_WINDOW_STATE_WITHDRAWN
constant GTK2.GDK_WINDOW_TEMP
constant GTK2.GDK_WINDOW_TOPLEVEL
constant GTK2.GDK_WINDOW_TYPE_HINT_DESKTOP
constant GTK2.GDK_WINDOW_TYPE_HINT_DIALOG
constant GTK2.GDK_WINDOW_TYPE_HINT_DOCK
constant GTK2.GDK_WINDOW_TYPE_HINT_MENU
constant GTK2.GDK_WINDOW_TYPE_HINT_NORMAL
constant GTK2.GDK_WINDOW_TYPE_HINT_SPLASHSCREEN
constant GTK2.GDK_WINDOW_TYPE_HINT_TOOLBAR
constant GTK2.GDK_WINDOW_TYPE_HINT_UTILITY
constant GTK2.GDK_XOR
constant GTK2.GDK_XTERM
constant GTK2.GDK_X_CURSOR
constant GTK2.GNOME_CLIENT_IS_CONNECTED
constant GTK2.GNOME_CLIENT_RESTARTED
constant GTK2.GNOME_CLIENT_RESTORED
constant GTK2.GNOME_DATE_EDIT_24_HR
constant GTK2.GNOME_DATE_EDIT_SHOW_TIME
constant GTK2.GNOME_DATE_EDIT_WEEK_STARTS_ON_MONDAY
constant GTK2.GNOME_DIALOG_ERROR
constant GTK2.GNOME_DIALOG_NORMAL
constant GTK2.GNOME_EDGE_FINISH
constant GTK2.GNOME_EDGE_LAST
constant GTK2.GNOME_EDGE_OTHER
constant GTK2.GNOME_EDGE_START
constant GTK2.GNOME_INTERACT_ANY
constant GTK2.GNOME_INTERACT_ERRORS
constant GTK2.GNOME_INTERACT_NONE
constant GTK2.GNOME_PREFERENCES_ALWAYS
constant GTK2.GNOME_PREFERENCES_NEVER
constant GTK2.GNOME_PREFERENCES_USER
constant GTK2.GNOME_RESTART_ANYWAY
constant GTK2.GNOME_RESTART_IF_RUNNING
constant GTK2.GNOME_RESTART_IMMEDIATELY
constant GTK2.GNOME_RESTART_NEVER
constant GTK2.GNOME_SAVE_BOTH
constant GTK2.GNOME_SAVE_GLOBAL
constant GTK2.GNOME_SAVE_LOCAL
constant GTK2.ACCEL_LOCKED
constant GTK2.ACCEL_MASK
constant GTK2.ACCEL_VISIBLE
constant GTK2.ANCHOR_CENTER
constant GTK2.ANCHOR_E
constant GTK2.ANCHOR_EAST
constant GTK2.ANCHOR_N
constant GTK2.ANCHOR_NE
constant GTK2.ANCHOR_NORTH
constant GTK2.ANCHOR_NORTH_EAST
constant GTK2.ANCHOR_NORTH_WEST
constant GTK2.ANCHOR_NW
constant GTK2.ANCHOR_S
constant GTK2.ANCHOR_SE
constant GTK2.ANCHOR_SOUTH
constant GTK2.ANCHOR_SOUTH_EAST
constant GTK2.ANCHOR_SOUTH_WEST
constant GTK2.ANCHOR_SW
constant GTK2.ANCHOR_W
constant GTK2.ANCHOR_WEST
constant GTK2.APP_PAINTABLE
constant GTK2.ARROW_DOWN
constant GTK2.ARROW_LEFT
constant GTK2.ARROW_RIGHT
constant GTK2.ARROW_UP
constant GTK2.BUTTONBOX_DEFAULT_STYLE
constant GTK2.BUTTONBOX_EDGE
constant GTK2.BUTTONBOX_END
constant GTK2.BUTTONBOX_SPREAD
constant GTK2.BUTTONBOX_START
constant GTK2.BUTTONS_CANCEL
constant GTK2.BUTTONS_CLOSE
constant GTK2.BUTTONS_NONE
constant GTK2.BUTTONS_OK
constant GTK2.BUTTONS_OK_CANCEL
constant GTK2.BUTTONS_YES_NO
constant GTK2.CALENDAR_NO_MONTH_CHANGE
constant GTK2.CALENDAR_SHOW_DAY_NAMES
constant GTK2.CALENDAR_SHOW_HEADING
constant GTK2.CALENDAR_SHOW_WEEK_NUMBERS
constant GTK2.CALENDAR_WEEK_START_MONDAY
constant GTK2.CAN_DEFAULT
constant GTK2.CAN_FOCUS
constant GTK2.CELL_RENDERER_FOCUSED
constant GTK2.CELL_RENDERER_INSENSITIVE
constant GTK2.CELL_RENDERER_MODE_ACTIVATABLE
constant GTK2.CELL_RENDERER_MODE_EDITABLE
constant GTK2.CELL_RENDERER_MODE_INERT
constant GTK2.CELL_RENDERER_PRELIT
constant GTK2.CELL_RENDERER_SELECTED
constant GTK2.CELL_RENDERER_SORTED
constant GTK2.CENTIMETERS
constant GTK2.COMPOSITE_CHILD
constant GTK2.CORNER_BOTTOM_LEFT
constant GTK2.CORNER_BOTTOM_RIGHT
constant GTK2.CORNER_TOP_LEFT
constant GTK2.CORNER_TOP_RIGHT
constant GTK2.CURVE_TYPE_FREE
constant GTK2.CURVE_TYPE_LINEAR
constant GTK2.CURVE_TYPE_SPLINE
constant GTK2.DATABOX_BARS
constant GTK2.DATABOX_CROSS_SIMPLE
constant GTK2.DATABOX_GRID
constant GTK2.DATABOX_LINES
constant GTK2.DATABOX_NOT_DISPLAYED
constant GTK2.DATABOX_POINTS
constant GTK2.DELETE_CHARS
constant GTK2.DELETE_DISPLAY_LINES
constant GTK2.DELETE_DISPLAY_LINE_ENDS
constant GTK2.DELETE_PARAGRAPHS
constant GTK2.DELETE_PARAGRAPH_ENDS
constant GTK2.DELETE_WHITESPACE
constant GTK2.DELETE_WORDS
constant GTK2.DELETE_WORD_ENDS
constant GTK2.DEST_DEFAULT_ALL
constant GTK2.DEST_DEFAULT_DROP
constant GTK2.DEST_DEFAULT_HIGHLIGHT
constant GTK2.DEST_DEFAULT_MOTION
constant GTK2.DIALOG_DESTROY_WITH_PARENT
constant GTK2.DIALOG_MODAL
constant GTK2.DIALOG_NO_SEPARATOR
constant GTK2.DIR_DOWN
constant GTK2.DIR_LEFT
constant GTK2.DIR_RIGHT
constant GTK2.DIR_TAB_BACKWARD
constant GTK2.DIR_TAB_FORWARD
constant GTK2.DIR_UP
constant GTK2.DOUBLE_BUFFERED
constant GTK2.EXPAND
constant GTK2.EXPANDER_COLLAPSED
constant GTK2.EXPANDER_EXPANDED
constant GTK2.EXPANDER_SEMI_COLLAPSED
constant GTK2.EXPANDER_SEMI_EXPANDED
constant GTK2.FILE_CHOOSER_ACTION_CREATE_FOLDER
constant GTK2.FILE_CHOOSER_ACTION_OPEN
constant GTK2.FILE_CHOOSER_ACTION_SAVE
constant GTK2.FILE_CHOOSER_ACTION_SELECT_FOLDER
constant GTK2.FILE_CHOOSER_ERROR_BAD_FILENAME
constant GTK2.FILE_CHOOSER_ERROR_NONEXISTENT
constant GTK2.FILE_FILTER_DISPLAY_NAME
constant GTK2.FILE_FILTER_FILENAME
constant GTK2.FILE_FILTER_MIME_TYPE
constant GTK2.FILE_FILTER_URI
constant GTK2.FILL
constant GTK2.FLOATING
constant GTK2.HAS_DEFAULT
constant GTK2.HAS_FOCUS
constant GTK2.HAS_GRAB
constant GTK2.ICON_LOOKUP_FORCE_SVG
constant GTK2.ICON_LOOKUP_NO_SVG
constant GTK2.ICON_LOOKUP_USE_BUILTIN
constant GTK2.ICON_SIZE_BUTTON
constant GTK2.ICON_SIZE_DIALOG
constant GTK2.ICON_SIZE_DND
constant GTK2.ICON_SIZE_INVALID
constant GTK2.ICON_SIZE_LARGE_TOOLBAR
constant GTK2.ICON_SIZE_MENU
constant GTK2.ICON_SIZE_SMALL_TOOLBAR
constant GTK2.ICON_THEME_FAILED
constant GTK2.ICON_THEME_NOT_FOUND
constant GTK2.IMAGE_ANIMATION
constant GTK2.IMAGE_EMPTY
constant GTK2.IMAGE_ICON_NAME
constant GTK2.IMAGE_ICON_SET
constant GTK2.IMAGE_IMAGE
constant GTK2.IMAGE_PIXBUF
constant GTK2.IMAGE_PIXMAP
constant GTK2.IMAGE_STOCK
constant GTK2.IM_PREEDIT_CALLBACK
constant GTK2.IM_PREEDIT_NONE
constant GTK2.IM_PREEDIT_NOTHING
constant GTK2.IM_STATUS_CALLBACK
constant GTK2.IM_STATUS_NONE
constant GTK2.IM_STATUS_NOTHING
constant GTK2.INCHES
constant GTK2.IN_DESTRUCTION
constant GTK2.JUSTIFY_CENTER
constant GTK2.JUSTIFY_FILL
constant GTK2.JUSTIFY_LEFT
constant GTK2.JUSTIFY_RIGHT
constant GTK2.MAPPED
constant GTK2.MENU_DIR_CHILD
constant GTK2.MENU_DIR_NEXT
constant GTK2.MENU_DIR_PARENT
constant GTK2.MENU_DIR_PREV
constant GTK2.MESSAGE_ERROR
constant GTK2.MESSAGE_INFO
constant GTK2.MESSAGE_QUESTION
constant GTK2.MESSAGE_WARNING
constant GTK2.MOVEMENT_BUFFER_ENDS
constant GTK2.MOVEMENT_DISPLAY_LINES
constant GTK2.MOVEMENT_DISPLAY_LINE_ENDS
constant GTK2.MOVEMENT_HORIZONTAL_PAGES
constant GTK2.MOVEMENT_LOGICAL_POSITIONS
constant GTK2.MOVEMENT_PAGES
constant GTK2.MOVEMENT_PARAGRAPHS
constant GTK2.MOVEMENT_PARAGRAPH_ENDS
constant GTK2.MOVEMENT_VISUAL_POSITIONS
constant GTK2.MOVEMENT_WORDS
constant GTK2.NO_REPARENT
constant GTK2.NO_SHOW_ALL
constant GTK2.NO_WINDOW
constant GTK2.ORIENTATION_HORIZONTAL
constant GTK2.ORIENTATION_VERTICAL
constant GTK2.PACK_END
constant GTK2.PACK_START
constant GTK2.PARENT_SENSITIVE
constant GTK2.PATH_CLASS
constant GTK2.PATH_PRIO_APPLICATION
constant GTK2.PATH_PRIO_GTK
constant GTK2.PATH_PRIO_HIGHEST
constant GTK2.PATH_PRIO_LOWEST
constant GTK2.PATH_PRIO_RC
constant GTK2.PATH_PRIO_THEME
constant GTK2.PATH_WIDGET
constant GTK2.PATH_WIDGET_CLASS
constant GTK2.PIXELS
constant GTK2.POLICY_ALWAYS
constant GTK2.POLICY_AUTOMATIC
constant GTK2.POLICY_NEVER
constant GTK2.POS_BOTTOM
constant GTK2.POS_LEFT
constant GTK2.POS_RIGHT
constant GTK2.POS_TOP
constant GTK2.PROGRESS_BOTTOM_TO_TOP
constant GTK2.PROGRESS_CONTINUOUS
constant GTK2.PROGRESS_DISCRETE
constant GTK2.PROGRESS_LEFT_TO_RIGHT
constant GTK2.PROGRESS_RIGHT_TO_LEFT
constant GTK2.PROGRESS_TOP_TO_BOTTOM
constant GTK2.RC_BASE
constant GTK2.RC_BG
constant GTK2.RC_FG
constant GTK2.RC_STYLE
constant GTK2.RC_TEXT
constant GTK2.RC_TOKEN_ACTIVE
constant GTK2.RC_TOKEN_APPLICATION
constant GTK2.RC_TOKEN_BASE
constant GTK2.RC_TOKEN_BG
constant GTK2.RC_TOKEN_BG_PIXMAP
constant GTK2.RC_TOKEN_BIND
constant GTK2.RC_TOKEN_BINDING
constant GTK2.RC_TOKEN_CLASS
constant GTK2.RC_TOKEN_ENGINE
constant GTK2.RC_TOKEN_FG
constant GTK2.RC_TOKEN_FONT
constant GTK2.RC_TOKEN_FONTSET
constant GTK2.RC_TOKEN_FONT_NAME
constant GTK2.RC_TOKEN_GTK
constant GTK2.RC_TOKEN_HIGHEST
constant GTK2.RC_TOKEN_IM_MODULE_FILE
constant GTK2.RC_TOKEN_IM_MODULE_PATH
constant GTK2.RC_TOKEN_INCLUDE
constant GTK2.RC_TOKEN_INSENSITIVE
constant GTK2.RC_TOKEN_INVALID
constant GTK2.RC_TOKEN_LAST
constant GTK2.RC_TOKEN_LOWEST
constant GTK2.RC_TOKEN_LTR
constant GTK2.RC_TOKEN_MODULE_PATH
constant GTK2.RC_TOKEN_NORMAL
constant GTK2.RC_TOKEN_PIXMAP_PATH
constant GTK2.RC_TOKEN_PRELIGHT
constant GTK2.RC_TOKEN_RC
constant GTK2.RC_TOKEN_RTL
constant GTK2.RC_TOKEN_SELECTED
constant GTK2.RC_TOKEN_STOCK
constant GTK2.RC_TOKEN_STYLE
constant GTK2.RC_TOKEN_TEXT
constant GTK2.RC_TOKEN_THEME
constant GTK2.RC_TOKEN_WIDGET
constant GTK2.RC_TOKEN_WIDGET_CLASS
constant GTK2.RC_TOKEN_XTHICKNESS
constant GTK2.RC_TOKEN_YTHICKNESS
constant GTK2.REALIZED
constant GTK2.RECEIVES_DEFAULT
constant GTK2.RELIEF_HALF
constant GTK2.RELIEF_NONE
constant GTK2.RELIEF_NORMAL
constant GTK2.RESERVED_1
constant GTK2.RESERVED_2
constant GTK2.RESIZE_IMMEDIATE
constant GTK2.RESIZE_PARENT
constant GTK2.RESIZE_QUEUE
constant GTK2.RESPONSE_ACCEPT
constant GTK2.RESPONSE_APPLY
constant GTK2.RESPONSE_CANCEL
constant GTK2.RESPONSE_CLOSE
constant GTK2.RESPONSE_DELETE_EVENT
constant GTK2.RESPONSE_HELP
constant GTK2.RESPONSE_NO
constant GTK2.RESPONSE_NONE
constant GTK2.RESPONSE_OK
constant GTK2.RESPONSE_REJECT
constant GTK2.RESPONSE_YES
constant GTK2.SCROLL_END
constant GTK2.SCROLL_ENDS
constant GTK2.SCROLL_HORIZONTAL_ENDS
constant GTK2.SCROLL_HORIZONTAL_PAGES
constant GTK2.SCROLL_HORIZONTAL_STEPS
constant GTK2.SCROLL_JUMP
constant GTK2.SCROLL_NONE
constant GTK2.SCROLL_PAGES
constant GTK2.SCROLL_PAGE_BACKWARD
constant GTK2.SCROLL_PAGE_DOWN
constant GTK2.SCROLL_PAGE_FORWARD
constant GTK2.SCROLL_PAGE_LEFT
constant GTK2.SCROLL_PAGE_RIGHT
constant GTK2.SCROLL_PAGE_UP
constant GTK2.SCROLL_START
constant GTK2.SCROLL_STEPS
constant GTK2.SCROLL_STEP_BACKWARD
constant GTK2.SCROLL_STEP_DOWN
constant GTK2.SCROLL_STEP_FORWARD
constant GTK2.SCROLL_STEP_LEFT
constant GTK2.SCROLL_STEP_RIGHT
constant GTK2.SCROLL_STEP_UP
constant GTK2.SELECTION_BROWSE
constant GTK2.SELECTION_MULTIPLE
constant GTK2.SELECTION_NONE
constant GTK2.SELECTION_SINGLE
constant GTK2.SENSITIVE
constant GTK2.SHADOW_ETCHED_IN
constant GTK2.SHADOW_ETCHED_OUT
constant GTK2.SHADOW_IN
constant GTK2.SHADOW_NONE
constant GTK2.SHADOW_OUT
constant GTK2.SHRINK
constant GTK2.SIZE_GROUP_BOTH
constant GTK2.SIZE_GROUP_HORIZONTAL
constant GTK2.SIZE_GROUP_NONE
constant GTK2.SIZE_GROUP_VERTICAL
constant GTK2.SORT_ASCENDING
constant GTK2.SORT_DESCENDING
constant GTK2.SOURCE_SEARCH_CASE_INSENSITIVE
constant GTK2.SOURCE_SEARCH_TEXT_ONLY
constant GTK2.SOURCE_SEARCH_VISIBLE_ONLY
constant GTK2.SPIN_END
constant GTK2.SPIN_HOME
constant GTK2.SPIN_PAGE_BACKWARD
constant GTK2.SPIN_PAGE_FORWARD
constant GTK2.SPIN_STEP_BACKWARD
constant GTK2.SPIN_STEP_FORWARD
constant GTK2.SPIN_USER_DEFINED
constant GTK2.STATE_ACTIVE
constant GTK2.STATE_INSENSITIVE
constant GTK2.STATE_NORMAL
constant GTK2.STATE_PRELIGHT
constant GTK2.STATE_SELECTED
constant GTK2.STOCK_ABOUT
constant GTK2.STOCK_ADD
constant GTK2.STOCK_APPLY
constant GTK2.STOCK_BOLD
constant GTK2.STOCK_CANCEL
constant GTK2.STOCK_CDROM
constant GTK2.STOCK_CLEAR
constant GTK2.STOCK_CLOSE
constant GTK2.STOCK_COLOR_PICKER
constant GTK2.STOCK_CONNECT
constant GTK2.STOCK_CONVERT
constant GTK2.STOCK_COPY
constant GTK2.STOCK_CUT
constant GTK2.STOCK_DELETE
constant GTK2.STOCK_DIALOG_AUTHENTICATION
constant GTK2.STOCK_DIALOG_ERROR
constant GTK2.STOCK_DIALOG_INFO
constant GTK2.STOCK_DIALOG_QUESTION
constant GTK2.STOCK_DIALOG_WARNING
constant GTK2.STOCK_DIRECTORY
constant GTK2.STOCK_DISCONNECT
constant GTK2.STOCK_DND
constant GTK2.STOCK_DND_MULTIPLE
constant GTK2.STOCK_EDIT
constant GTK2.STOCK_EXECUTE
constant GTK2.STOCK_FILE
constant GTK2.STOCK_FIND
constant GTK2.STOCK_FIND_AND_REPLACE
constant GTK2.STOCK_FLOPPY
constant GTK2.STOCK_FULLSCREEN
constant GTK2.STOCK_GOTO_BOTTOM
constant GTK2.STOCK_GOTO_FIRST
constant GTK2.STOCK_GOTO_LAST
constant GTK2.STOCK_GOTO_TOP
constant GTK2.STOCK_GO_BACK
constant GTK2.STOCK_GO_DOWN
constant GTK2.STOCK_GO_FORWARD
constant GTK2.STOCK_GO_UP
constant GTK2.STOCK_HARDDISK
constant GTK2.STOCK_HELP
constant GTK2.STOCK_HOME
constant GTK2.STOCK_INDENT
constant GTK2.STOCK_INDEX
constant GTK2.STOCK_INFO
constant GTK2.STOCK_ITALIC
constant GTK2.STOCK_JUMP_TO
constant GTK2.STOCK_JUSTIFY_CENTER
constant GTK2.STOCK_JUSTIFY_FILL
constant GTK2.STOCK_JUSTIFY_LEFT
constant GTK2.STOCK_JUSTIFY_RIGHT
constant GTK2.STOCK_LEAVE_FULLSCREEN
constant GTK2.STOCK_MEDIA_FORWARD
constant GTK2.STOCK_MEDIA_NEXT
constant GTK2.STOCK_MEDIA_PAUSE
constant GTK2.STOCK_MEDIA_PLAY
constant GTK2.STOCK_MEDIA_PREVIOUS
constant GTK2.STOCK_MEDIA_RECORD
constant GTK2.STOCK_MEDIA_REWIND
constant GTK2.STOCK_MEDIA_STOP
constant GTK2.STOCK_MISSING_IMAGE
constant GTK2.STOCK_NETWORK
constant GTK2.STOCK_NEW
constant GTK2.STOCK_NO
constant GTK2.STOCK_OK
constant GTK2.STOCK_OPEN
constant GTK2.STOCK_PASTE
constant GTK2.STOCK_PREFERENCES
constant GTK2.STOCK_PRINT
constant GTK2.STOCK_PRINT_PREVIEW
constant GTK2.STOCK_PROPERTIES
constant GTK2.STOCK_QUIT
constant GTK2.STOCK_REDO
constant GTK2.STOCK_REFRESH
constant GTK2.STOCK_REMOVE
constant GTK2.STOCK_REVERT_TO_SAVED
constant GTK2.STOCK_SAVE
constant GTK2.STOCK_SAVE_AS
constant GTK2.STOCK_SELECT_COLOR
constant GTK2.STOCK_SELECT_FONT
constant GTK2.STOCK_SORT_ASCENDING
constant GTK2.STOCK_SORT_DESCENDING
constant GTK2.STOCK_SPELL_CHECK
constant GTK2.STOCK_STOP
constant GTK2.STOCK_STRIKETHROUGH
constant GTK2.STOCK_UNDELETE
constant GTK2.STOCK_UNDERLINE
constant GTK2.STOCK_UNDO
constant GTK2.STOCK_UNINDENT
constant GTK2.STOCK_YES
constant GTK2.STOCK_ZOOM_100
constant GTK2.STOCK_ZOOM_FIT
constant GTK2.STOCK_ZOOM_IN
constant GTK2.STOCK_ZOOM_OUT
constant GTK2.TARGET_SAME_APP
constant GTK2.TARGET_SAME_WIDGET
constant GTK2.TEXT_DIR_LTR
constant GTK2.TEXT_DIR_NONE
constant GTK2.TEXT_DIR_RTL
constant GTK2.TEXT_SEARCH_TEXT_ONLY
constant GTK2.TEXT_SEARCH_VISIBLE_ONLY
constant GTK2.TEXT_WINDOW_BOTTOM
constant GTK2.TEXT_WINDOW_LEFT
constant GTK2.TEXT_WINDOW_PRIVATE
constant GTK2.TEXT_WINDOW_RIGHT
constant GTK2.TEXT_WINDOW_TEXT
constant GTK2.TEXT_WINDOW_TOP
constant GTK2.TEXT_WINDOW_WIDGET
constant GTK2.TOOLBAR_BOTH
constant GTK2.TOOLBAR_BOTH_HORIZ
constant GTK2.TOOLBAR_ICONS
constant GTK2.TOOLBAR_SPACE_EMPTY
constant GTK2.TOOLBAR_SPACE_LINE
constant GTK2.TOOLBAR_TEXT
constant GTK2.TOPLEVEL
constant GTK2.TREE_MODEL_ITERS_PERSIST
constant GTK2.TREE_MODEL_LIST_ONLY
constant GTK2.TREE_VIEW_COLUMN_AUTOSIZE
constant GTK2.TREE_VIEW_COLUMN_FIXED
constant GTK2.TREE_VIEW_COLUMN_GROW_ONLY
constant GTK2.TREE_VIEW_DROP_AFTER
constant GTK2.TREE_VIEW_DROP_BEFORE
constant GTK2.TREE_VIEW_DROP_INTO_OR_AFTER
constant GTK2.TREE_VIEW_DROP_INTO_OR_BEFORE
constant GTK2.UI_MANAGER_ACCELERATOR
constant GTK2.UI_MANAGER_AUTO
constant GTK2.UI_MANAGER_MENU
constant GTK2.UI_MANAGER_MENUBAR
constant GTK2.UI_MANAGER_MENUITEM
constant GTK2.UI_MANAGER_PLACEHOLDER
constant GTK2.UI_MANAGER_POPUP
constant GTK2.UI_MANAGER_SEPARATOR
constant GTK2.UI_MANAGER_TOOLBAR
constant GTK2.UI_MANAGER_TOOLITEM
constant GTK2.UPDATE_ALWAYS
constant GTK2.UPDATE_CONTINUOUS
constant GTK2.UPDATE_DELAYED
constant GTK2.UPDATE_DISCONTINUOUS
constant GTK2.UPDATE_IF_VALID
constant GTK2.VISIBILITY_FULL
constant GTK2.VISIBILITY_NONE
constant GTK2.VISIBILITY_PARTIAL
constant GTK2.VISIBLE
constant GTK2.WIDGET_HELP_TOOLTIP
constant GTK2.WIDGET_HELP_WHATS_THIS
constant GTK2.WINDOW_POPUP
constant GTK2.WINDOW_TOPLEVEL
constant GTK2.WIN_POS_CENTER
constant GTK2.WIN_POS_CENTER_ALWAYS
constant GTK2.WIN_POS_CENTER_ON_PARENT
constant GTK2.WIN_POS_MOUSE
constant GTK2.WIN_POS_NONE
constant GTK2.WRAP_CHAR
constant GTK2.WRAP_NONE
constant GTK2.WRAP_WORD
constant GTK2.WRAP_WORD_CHAR
constant GTK2.PANGO_ATTR_BACKGROUND
constant GTK2.PANGO_ATTR_FALLBACK
constant GTK2.PANGO_ATTR_FAMILY
constant GTK2.PANGO_ATTR_FONT_DESC
constant GTK2.PANGO_ATTR_FOREGROUND
constant GTK2.PANGO_ATTR_INVALID
constant GTK2.PANGO_ATTR_LANGUAGE
constant GTK2.PANGO_ATTR_LETTER_SPACING
constant GTK2.PANGO_ATTR_RISE
constant GTK2.PANGO_ATTR_SCALE
constant GTK2.PANGO_ATTR_SHAPE
constant GTK2.PANGO_ATTR_SIZE
constant GTK2.PANGO_ATTR_STRETCH
constant GTK2.PANGO_ATTR_STRIKETHROUGH
constant GTK2.PANGO_ATTR_STYLE
constant GTK2.PANGO_ATTR_UNDERLINE
constant GTK2.PANGO_ATTR_VARIANT
constant GTK2.PANGO_ATTR_WEIGHT
constant GTK2.PANGO_FONT_MASK_FAMILY
constant GTK2.PANGO_FONT_MASK_SIZE
constant GTK2.PANGO_FONT_MASK_STRETCH
constant GTK2.PANGO_FONT_MASK_STYLE
constant GTK2.PANGO_FONT_MASK_VARIANT
constant GTK2.PANGO_FONT_MASK_WEIGHT
constant GTK2.PANGO_SCALE
constant GTK2.PANGO_SCALE_LARGE
constant GTK2.PANGO_SCALE_MEDIUM
constant GTK2.PANGO_SCALE_SMALL
constant GTK2.PANGO_SCALE_XX_LARGE
constant GTK2.PANGO_SCALE_XX_SMALL
constant GTK2.PANGO_SCALE_X_LARGE
constant GTK2.PANGO_SCALE_X_SMALL
constant GTK2.PANGO_STRETCH_CONDENSED
constant GTK2.PANGO_STRETCH_EXPANDED
constant GTK2.PANGO_STRETCH_EXTRA_CONDENSED
constant GTK2.PANGO_STRETCH_EXTRA_EXPANDED
constant GTK2.PANGO_STRETCH_NORMAL
constant GTK2.PANGO_STRETCH_SEMI_CONDENSED
constant GTK2.PANGO_STRETCH_SEMI_EXPANDED
constant GTK2.PANGO_STRETCH_ULTRA_CONDENSED
constant GTK2.PANGO_STRETCH_ULTRA_EXPANDED
constant GTK2.PANGO_STYLE_ITALIC
constant GTK2.PANGO_STYLE_NORMAL
constant GTK2.PANGO_STYLE_OBLIQUE
constant GTK2.PANGO_TAB_LEFT
constant GTK2.PANGO_UNDERLINE_DOUBLE
constant GTK2.PANGO_UNDERLINE_ERROR
constant GTK2.PANGO_UNDERLINE_LOW
constant GTK2.PANGO_UNDERLINE_NONE
constant GTK2.PANGO_UNDERLINE_SINGLE
constant GTK2.PANGO_VARIANT_NORMAL
constant GTK2.PANGO_VARIANT_SMALL_CAPS
constant GTK2.PANGO_WEIGHT_BOLD
constant GTK2.PANGO_WEIGHT_HEAVY
constant GTK2.PANGO_WEIGHT_LIGHT
constant GTK2.PANGO_WEIGHT_NORMAL
constant GTK2.PANGO_WEIGHT_ULTRABOLD
constant GTK2.PANGO_WEIGHT_ULTRALIGHT
constant GTK2.TRUE
void add_builtin_icon(string name, int size, GTK2.GdkPixbuf pixbuf)
Registers a built-in icon for icon theme lookups. The idea of build-in icons is to allow an application or library that uses themed icons to function requiring files to be present in the file system. For instance, the default images for all of GTK2+'s stock icons are registered as built-in icons.
In general, if you use add_builtin_icon() you should also install the icon in the icon theme, so that the icon is generally available.
int false()
Always returns false.
void flush()
Flush GDK. Not normally needed, can be useful while doing calculations.
array get_default_icon_list()
Gets the value set by set_default_icon_list().
GTK2.IconTheme get_default_icon_theme()
Gets the icon theme.
mapping get_file_info(string filename)
Parses an image file far enough to determine its format and size.
array get_formats()
Get information about the image formats supported.
array gnome_init(string app_id, string app_version, array argv)
Initializes the application. This sets up all of the GNOME internals and prepares them (gdk/gtk, session-management, triggers, sound, user preferences). If corba init flags are specified, corba initialization is done as well as gnome initialization. corba_init_flags is 0 or more of GNORBA_INIT_SERVER_FUNC (1), GNORBA_INIT_DISABLE_COOKIES (2) and GNORBA_INIT_CORBA_PRIO_HIGH (4)
void grab_add(GTK2.Widget widget)
Grab a widget.
void grab_remove(GTK2.Widget widget)
Remove the grab.
array gtk_init(array|void argc, int|void no_pgtkrc)
Low level GTK init function (used by setup_gtk). This function is more or less equivalent to the C-GTK+ function gtk_init. setup_gtk does some extra things (such as parsing ~/.pgtkrc).
array list_toplevels()
Returns a list of all existing toplevel windows.
void low_flush()
Flush, but do not process events. Not normally needed.
void main()
Start GTK in blocking mode. Doing this disables asynchronous I/O in pike. You can return -1 from main in pike to run GTK (and the rest of pike) in asynchronous mode.
int main_iteration_do(int block)
Run one iteration in the mainloop. If block is true, wait for an event before returning.
int main_level()
Return the current recursion depth.
void main_quit()
Exit from the gtk_main function on the next iteration.
void parse_rc(string rc)
Takes a string and reads it as a gtkrc file.
GTK2.GdkWindow root_window()
Returns the root window of the current display
void set_auto_startup_notification(int setting)
By default, after showing the first GTK2.Window for each GDK2.Screen, GTK+ calls GDK2.Screen->notify_startup_complete(). Call this function to disable the automatic startup notification. You might do this if your first window is a splash screen, and you want to delay notification until after your real main window has been shown, for example.
In that example, you would disable startup notification temporarily, show your splash screen, then re-enable it so that showing the main window would automatically result in notification.
void set_default_icon(GTK2.GdkPixbuf pix)
Sets an icon to be used as fallback for windows that haven't had set_icon() called on them.
void set_default_icon_from_file(string filename)
Sets an icon to be used as fallback from a file on disk.
void set_default_icon_list(array list)
Sets an icon list to be used as fallback for windows that haven't had set_icon_list() called on them to set up a window-specific icon list. This function allows you to set up the icon for all windows in your app at once.
void set_default_icon_name(string name)
Sets an icon to be used as fallback for windows that haven't had set_icon_list() called on them from a named themed icon.
array setup_gtk(array|void argv, int|void do_not_parse_rc)
Initialize GTK, and all that comes with it. Also parses $HOME/.pgtkrc and $HOME/.gtkrc if they exists. The single argument, if supplied, is the argument array passed to the program. This is used to set default window titles etc. The second argument, if supplied, indicates that pike specific *rc files should not be parsed.
The most common usage is GTK2.setup_gtk(argv);
int true()
Always returns true.
array version()
Returns the version of the GTK library.
| CLASS GTK2.TreePath |
TreePath.
GTK2.TreePath append_index(int index)
Appends a new index to path. As a result, the depth of the path is increased.
int compare(GTK2.TreePath b)
Compares two paths. If this path appears before b, -1 is returned. If b before this path, 1 is return. If they are equal, 0 is returned.
GTK2.TreePath copy()
Creates a new GTK2.TreePath as a copy.
GTK2.TreePath GTK2.TreePath(string|void path)
Creates a new GTK2.TreePath.
GTK2.TreePath down()
Moves path to point to the first child of the current path.
int get_depth()
Returns the current depth of path.
array get_indices()
Returns the current indices of path as an array of integers, each representing a node in a tree.
int is_ancestor(GTK2.TreePath descendant)
Returns TRUE if descendant is a descendant of this path.
int is_descendant(GTK2.TreePath ancestor)
Returns TRUE if this path is a descendant of ancestor.
GTK2.TreePath next()
Moves the path to point to the next node at the current depth.
GTK2.TreePath prepend_index(int index)
Prepends a new index to a path. As a result, the depth of the path is increased.
GTK2.TreePath prev()
Moves the path to point to the previous node at the current depth, if it exists. Returns TRUE if the move was made.
string to_string()
Generates a string representation of the path. This string is a ':' separated list of numbers. For example, "4:10:0:3" would be an acceptable return value for this string.
GTK2.TreePath up()
Moves the path to point to its parent node, if it has a parent.
| CLASS GTK2.Window |
The basic window. Nothing much to say about it. It can only contain one child widget. Show the main window last to avoid annoying flashes when the subwidget (and it's subwidgets) are added to it, this is done automatically by calling 'window->show_all' when you are done with your widget packing. Properties: int accept-focus int allow-grow int allow-shrink int decorated int default-height int default-width int destroy-with-parent int focus-on-map int gravity GDK_GRAVITY_CENTER , GDK_GRAVITY_EAST , GDK_GRAVITY_NORTH , GDK_GRAVITY_NORTH_EAST , GDK_GRAVITY_NORTH_WEST , GDK_GRAVITY_SOUTH , GDK_GRAVITY_SOUTH_EAST , GDK_GRAVITY_SOUTH_WEST , GDK_GRAVITY_STATIC and GDK_GRAVITY_WEST int has-toplevel-focus GDK2.Pixbuf icon string icon-name int is-active int modal int resizable string role GDK2.Screen screen int skip-pager-hint int skip-taskbar-hint string title GTK2.Window transient-for int type WINDOW_POPUP and WINDOW_TOPLEVEL int type-hint GDK_WINDOW_TYPE_HINT_DESKTOP , GDK_WINDOW_TYPE_HINT_DIALOG , GDK_WINDOW_TYPE_HINT_DOCK , GDK_WINDOW_TYPE_HINT_MENU , GDK_WINDOW_TYPE_HINT_NORMAL , GDK_WINDOW_TYPE_HINT_SPLASHSCREEN , GDK_WINDOW_TYPE_HINT_TOOLBAR and GDK_WINDOW_TYPE_HINT_UTILITY int urgency-hint int window-position WIN_POS_CENTER , WIN_POS_CENTER_ALWAYS , WIN_POS_CENTER_ON_PARENT , WIN_POS_MOUSE and WIN_POS_NONE
Signals: activate_default
activate_focus
frame_event
keys_changed
move_focus
set_focus
inherit GTK2.Bin : Bin
int activate_default()
Activates the default widget, unless the current focused widget has been configured to receive the default action, in which case the focuses widget is activated.
int activate_focus()
Activates the current focused widget.
GTK2.Window add_accel_group(GTK2.AccelGroup group)
This function adds an accelerator group to the window. The shortcuts in the table will work in the window, it's child, and all children of it's child that do not select keyboard input.
GTK2.Window add_mnemonic(int keyval, GTK2.Widget target)
Adds a mnemonic to this window.
GTK2.Window begin_move_drag(int button, int root_x, int root_y, int timestamp)
Starts moving a window. This function is used if an application has window movement grips.
GTK2.Window begin_resize_drag(int edge, int button, int root_x, int root_y, int timestamp)
Starts resizing a window. This function is used if an application has window resizing controls. When GDK can support it, the resize will be done using the standard mechanism for the window manager or windowing system.
GTK2.Window GTK2.Window(int|mapping props)
Argument is one of WINDOW_POPUP and WINDOW_TOPLEVEL , or a mapping of allowed properties.
GTK2.Window deiconify()
Opposite of iconify().
GTK2.Window fullscreen()
Asks to place this window in the fullscreen state. Same caveats iconify().
int get_accept_focus()
Gets the value set by set_accept_focus().
int get_decorated()
Returns whether the window has been set to have decorations such as a title bar.
mapping get_default_size()
Gets the default size of the window. A value of -1 for the width or height indicates that a default size has not been explicitly set for that dimeension, so the "natural" size of the window will be used.
int get_destroy_with_parent()
Returns whether the window will be destroyed with its transient parent.
GTK2.Widget get_focus()
Retrieves the current focused widget within the window. Note that this is the widget that would have the focus if the toplevel window focused; if the toplevel window is not focused then has_focus() will not be true for the widget.
int get_focus_on_map()
Gets the value set by set_focus_on_map().
GTK2.Window get_gravity()
Gets the value set by set_gravity().
GTK2.GdkPixbuf get_icon()
Gets the value set by set_icon().
array get_icon_list()
Retrieves the list of icons set by set_icon_list().
string get_icon_name()
Returns the name of the themed icon for the window.
int get_mnemonic_modifier()
Returns the mnemonic modifier for this window.
int get_modal()
Returns whether the window is modal.
mapping get_position()
This function returns the position you need to pass to move() to keep this window in its current position. This means that the meaning of the returned value varies with window gravity.
If you haven't changed the window gravity, its gravity will be GDK2.GRAVITY_NORTH_WEST. This means that get_position() gets the position of the top-left corner of the window manager frame for the window. move() sets the position of this same top-left corner.
get_position() is not 100% reliable because X does not specify a way to obtain the geometry of the decorations placed on a window by the window manager. Thus GTK+ is using a "best guess" that works with most window managers.
Moreover, nearly all window managers are historically broken with respect to their handling of window gravity. So moving a window to its current position as returned by get_position() tends to result in moving the window slightly. Window managers are slowly getting better over time.
If a window has gravity GDK2.GRAVITY_STATIC the window manager frame is not relevant, and thus get_position() will always produc accurate results. However you can't use static gravity to do things like place a window in a corner of the screen, because static gravity ignores the window manager decorations.
If you are saving and restoring your application's window positions, you should know that it's impossible for applications to do this without getting it somewhat wrong because applications do not have sufficient knowledge of window manager state.
GTK2.Window get_resizable()
Gets the whether this window is resizable.
mapping get_size()
Obtains the current size of window.
int get_skip_pager_hint()
Gets the value set by set_skip_pager_hint().
int get_skip_taskbar_hint()
Gets the value set by set_skip_taskbar_hint().
string get_title()
Retrieves the title of the window.
GTK2.Window get_transient_for()
Fetches the transient parent for this window.
int get_type_hint()
Gets the type hint.
int get_urgency_hint()
Gets the value set by set_urgency_hint().
int has_toplevel_focus()
Returns whether the input focus is within this window. For real toplevel windows, this is identical to is_active(), but for embedded windows, like W(Plug), the results will differ.
GTK2.Window iconify()
Asks to iconify (minimize) this window. Note that you shouldn't assume the window is definitely iconified afterward, because other entities (e.g. the user or window manager) could deiconify it again, or there may not be a window manager in which case iconification isn't possible, etc.
int is_active()
Returns whether the window is part of the current active toplevel. (That is, the toplevel window receiving keystrokes.) The return value is true if the window is active toplevel itself, but also if it is, say, a W(Plug) embedded in the active toplevel. You might use this function if you wanted to draw a widget differently in an active window from a widget in an inactive window().
GTK2.Window lower()
Lower this window if the window manager allows that.
GTK2.Window maximize()
Maximize a window. Same caveats as iconify().
int mnemonic_activate(int keyval, int modifier)
Activates the targets associated with the mnemonic. modifier is one of GDK2.SHIFT_MASK, GDK2.LOCK_MASK, GDK2.CONTROL_MASK, GDK2.MOD1_MASK, GDK2.MOD2_MASK, GDK2.MOD3_MASK, GDK2.MOD4_MASK, GDK2.MOD5_MASK, GDK2.BUTTON1_MASK, GDK2.BUTTON2_MASK, GDK2.BUTTON3_MASK, GDK2.BUTTON4_MASK GDK2.BUTTON5_MASK, GDK2.RELEASE_MASK, GDK2.MODIFIER_MASK
GTK2.Window move(int x, int y)
Asks the window manage to move the window to the given position. Window managers are free to ignore this; most window managers ignore request for initial window positions (instead using a user-defined placement algorithm) and honor requests after the window has already been shown.
Note: the position is the position of the gravity-determined reference point for the window. The gravity determines two things: first, the location of the reference point in root window coordinates; and second, which point on the window is position at the reference point.
By default the gravity is GDK2.GRAVITY_NORTH_WEST, so the reference point is simply the x,y supplied to move(). The top-left corner of the window decorations (aka window frame or border) will be place at x,y. Therefore, to position a window at the top left of the screen, you want to use the default gravity (which is GDK2.GRAVITY_NORTH_WEST) and move the window to 0,0.
To position a window at the bottom right corner of the screen, you would set GDK2.GRAVITY_SOUTH_EAST, which means that the reference point is at x + the window width and y + the window height, and the bottom-right corner of the window border will be placed at that reference point.
int parse_geometry(string geometry)
Parses a standard X geometry string.
GTK2.Window present()
Presents this window to the user. This may mean raising the window in the stacking order, deiconifying it, moving it to the current desktop, and/or giving it the keyboard focus, possibly dependent on the user's platform, window manager, and preferences.
If hidden, it calls show() as well.
GTK2.Window present_with_time(int timestamp)
Presents a window to the user with a timestamp. See present().
GTK2.Window raise()
Raise this window if the window manager allows that.
GTK2.Window remove_accel_group(GTK2.AccelGroup group)
Reverses the effects of add_accel_group().
GTK2.Window remove_mnemonic(int keyval, GTK2.Widget target)
Removes a mnemonic from this window.
GTK2.Window reshow_with_initial_size()
Hides the window, then reshows it, resetting the default size and position of the window.
GTK2.Window resize(int width, int height)
Resizes the window as if the user had done so, obeying geometry constraints.
GTK2.Window set_accept_focus(int setting)
Windows may set a hint asking the desktop environment not to receive the input focus.
GTK2.Window set_decorated(int setting)
Add title bar, resize controls, etc. Default is true, so you may only need to use this function if you want to remove decorations. Depending on the system, this function may not have any effect when called on a window that is already visible, so you should call it before calling show().
GTK2.Window set_default(GTK2.Widget child)
The default widget is the widget that's activated when the user presses Enter in a dialog (for example). This function sets or unsets the default widget. When setting (rather than unsetting) the default widget it's generally easier to call GTK2.Widget->grab_focus() on the widget.
GTK2.Window set_default_size(int width, int height)
Sets the default size of a window. If the window's "natural" size (its size request) is larger than the default, the default will be ignored. more generally, if the default size does not obey the geometry hints for the window (set_geometry_hints() can be used to set these explicitly), the default size will be clamped to the nearest permitted size.
Unlike set_size_request(), which sets a size request for a widget and thus would keep users from shrinking the window, this function only sets the initial size, just as if the user had resized the window themselves. Users can still shrink the window again as they normally would. Setting a default size of -1 means to use the "natural" default size (the size request of the window).
For more control over a window's initial size and how resizing works, investigate set_geometry_hints().
For some uses, resize() is a more appropriate function. resize() changes the current size of the window, rather than the size to be used on initial display. resize() always affects the window itself, not the geometry widget.
The default size of a window only affects the first time a window is shown; if a window is hidden and re-shown, it will remember the size it had prior to hiding, rather than using the default size.
Window scan't actually be 0x0 in size, they must be at least 1x1, but passing 0 for width and height is OK, resulting in a 1x1 default size.
GTK2.Window set_destroy_with_parent(int setting)
If setting is true, then destroying the transient parent of this window will also destroy the window itself. This is useful for dialogs that shouldn't persist beyond the lifetime of the main window they're associated with, for example.
GTK2.Window set_focus(GTK2.Widget child)
If child is not the current focus widget, and is focusable, sets it as the focus widget for the window. If child is 0, unsets the focus widget for this window. To set the focus to a particular widget in the toplevel, it is usually more convenient to use GTK2.Widget->grab_focus() instead of this function.
GTK2.Window set_focus_on_map(int setting)
Windows may set a hint asking the desktop environment not to receive the input focus when the window is mapped.
GTK2.Window set_geometry_hints(GTK2.Widget widget, mapping geometry)
This function sets up hints about how a window can be resized by the user. You can set a minimum and maximum size; allowed resized increments (e.g. for xterm, you can only resize by the size of a character); aspect ratios; and more. geometry is a mapping with the following fields. Any field which is omitted is left as the default: ([ "min_width": int, "min_height": int, "max_width": int, "max_height": int, "base_width": int, "base_height": int, "width_inc": int, "height_inc": int, "min_aspect": float, "max_aspect": float, "win_gravity": int, GDK_GRAVITY_CENTER , GDK_GRAVITY_EAST , GDK_GRAVITY_NORTH , GDK_GRAVITY_NORTH_EAST , GDK_GRAVITY_NORTH_WEST , GDK_GRAVITY_SOUTH , GDK_GRAVITY_SOUTH_EAST , GDK_GRAVITY_SOUTH_WEST , GDK_GRAVITY_STATIC and GDK_GRAVITY_WEST ]); min_width/min_height/max_width/max_height may be set to -1, and it will substitute the size request of the window or geometry widget. If the minimum size hint is not provided, it will use its requisition as the minimum size. If the minimum size is provided and a geometry widget is set, it will take the minimum size as the minimum size of the geometry widget rather than the entire window. The base size is treat similarly. min_width: minimum width of the window (-1 to use requisition) min_height: minimum height of window (-1 to use requisition) max_width: maximum width of window (-1 to use requisition) max_height: maximum height of window (-1 to use requisition) base_width: allow window widths are base_width+width_inc*N (-1 allowed) base_height: allowed window widths are base_height+height_inc*N (-1 allowed) width_inc: width resize increment height_inc: height resize increment min_aspect: minimum width/height ratio max_aspect: maximum width/height ratio win_gravity: window gravity
GTK2.Window set_gravity(int gravity)
Window gravity defines the meaning of coordinates passed to move().
The default window gravity is GDK2.GRAVITY_NORTH_WEST, which will typically "do what you mean."
GTK2.Window set_icon(GTK2.GdkPixbuf icon)
Sets up the icon representing this window. This icon is used when the window is minimized (also know as iconified). Some window managers or desktop environments may also place it in the window frame, or display it in other contexts.
The icon should be provided in whatever size it was naturally drawn; that is, don't scale the image before passing it. Scaling is postponed until the last minute, when the desired final size is known, to allow best quality.
If you have your icon hand-drawn in multiple sizes, use set_icon_list(). Then the best size will be used.
int set_icon_from_file(string filename)
Sets the icon from a file.
GTK2.Window set_icon_list(array list)
Set up the icons for minimizing.
set_icon_list() allows you to pass in the same icon in several hand-drawn sizes. The list should contain the natural sizes your icon is avilable in; that is, don't scale the image before passing it. Scaling is postponed until the last minute, when the desired final size is known, to allow best quality.
By passing several sizes, you may improve the final image quality of the icon, by reducing or eliminating automatic image scaling.
Recommended sizes to provide: 16x16, 32x32, 48x48 at minimum, and larger images (64x64, 128x128) if you have them.
GTK2.Window set_icon_name(string name)
Sets the icon for the window from a named themed icon.
GTK2.Window set_keep_above(int setting)
Keep window above.
GTK2.Window set_keep_below(int setting)
Keep window below.
GTK2.Window set_mnemonic_modifier(int modifier)
Sets the mnemonic modifer for this window.
GTK2.Window set_modal(int setting)
Sets a window modal or non-modal. Modal windows prevent interaction with other windows in the same application. To keep modal dialogs on top of main application windows, use set_transient_for() to make the dialog transient for the parent; most window managers will then disallow lowering the dialog below the parent.
GTK2.Window set_position(int pos)
Sets a position contraint for this window. If the old or new constraint is GTK2.WIN_POS_CENTER_ALWAYS, this will also cause the window to be repositioned to satisfy the new constraint.
GTK2.Window set_resizable(int setting)
Sets whether the user can resize a window. Windows are user resizable by default.
GTK2.Window set_skip_pager_hint(int setting)
Windows may set a hint asking the desktop environment not to display the window in the pager.
GTK2.Window set_skip_taskbar_hint(int setting)
Windows may set a hint asking the desktop environment not to display the window in the task bar. This function sets this hint.
GTK2.Window set_title(string title)
Set the window title. The default title is the value sent to setup_gtk, or if none is sent, Pike GTK.
GTK2.Window set_transient_for(GTK2.Window parent)
Dialog window should be set transient for the main application window they were spawned from. This allows window managers to e.g. keep the dialog on top of the main window, or center the dialog over the main window. W(Dialog) and other convenience objects in GTK+ will sometimes call set_transient_for on your behalf.
GTK2.Window set_type_hint(int hint)
Set type of window. Values are GDK_WINDOW_TYPE_HINT_DESKTOP , GDK_WINDOW_TYPE_HINT_DIALOG , GDK_WINDOW_TYPE_HINT_DOCK , GDK_WINDOW_TYPE_HINT_MENU , GDK_WINDOW_TYPE_HINT_NORMAL , GDK_WINDOW_TYPE_HINT_SPLASHSCREEN , GDK_WINDOW_TYPE_HINT_TOOLBAR and GDK_WINDOW_TYPE_HINT_UTILITY
GTK2.Window set_urgency_hint(int setting)
Windows may set a hint asking the desktop environment to draw the users attention to the window. This function sets this hint.
GTK2.Window set_wmclass(string name, string class)
Set the window manager application name and class.
GTK2.Window stick()
Makes this window sticky. Same caveats as iconify().
GTK2.Window unfullscreen()
Opposite of fullscreen().
GTK2.Window unmaximize()
Opposite of maximize().
GTK2.Window unstick()
Opposite of stick().
| CLASS GTK2.TreeRowReference |
A TreeRowReference.
GTK2.TreeRowReference copy()
Copies a GTK2.TreeRowReference.
GTK2.TreeRowReference GTK2.TreeRowReference(GTK2.TreeModel model, GTK2.TreePath path)
Creates a row reference based on path. This reference will keep pointing to the node pointed to by path, so long as it exists.
GTK2.TreeModel get_model()
Returns the model which this references is monitoring.
GTK2.TreePath get_path()
Returns a path that the row reference currently points to.
int valid()
Return TRUE if the reference referes to a current valid path.
| CLASS GTK2.Dialog |
A dialog is a window with a few default widgets added. The 'vbox' is the main content area of the widget. The 'action_area' is allocated for buttons (ok, cancel etc) Properties: int has-separator
Style properties: int action-area-border int button-spacing int content-area-border
Signals: close
response
inherit GTK2.Window : Window
GTK2.Dialog add_action_widget(GTK2.Widget child, int response_id)
Adds an activatable widget to the action area, connecting a signal handler that will emit the "response" signal on the dialog when the widget is activated.
GTK2.Widget add_button(string button_text, int response_id)
Adds a button with the given text (or a stock button) and sets things up so that clicking the button will emit the "response" signal with the given response_id.
GTK2.Dialog GTK2.Dialog(mapping|void props)
Create a new dialog widget.
GTK2.HbuttonBox get_action_area()
The action area, this is where the buttons (ok, cancel etc) go
int get_has_separator()
Accessor for whether the dialog has a separator.
int get_response_for_widget(GTK2.Widget widget)
Gets the response id of a widget in the action area.
GTK2.Vbox get_vbox()
The vertical box that should contain the contents of the dialog
GTK2.Dialog response(int response_id)
Emits the "response" signal with the given response ID.
int run()
Run the selected dialog.
GTK2.Dialog set_default_response(int response_id)
Sets the last widget in the action area with the given response_id as the default widget. Pressing "Enter" normally activates the default widget.
GTK2.Dialog set_has_separator(int setting)
Sets whether this dialog has a separator above the buttons. True by default.
GTK2.Dialog set_response_sensitive(int response_id, int setting)
Calls GTK2.Widget->set_sensitive() for each widget in the dialog's action area with the given response_id.
| CLASS GTK2.Pango.LayoutIter |
PangoLayoutIter.
int at_last_line()
Determines whether this iter is on the last line of the layout.
int get_baseline()
Gets the y position of the current line's baseline, in layout coordinates (origin at top left of the entire layout).
mapping get_char_extents()
Gets the extents of the current character, in layout coordinates (origin is the top left of the entire layout).
array get_cluster_extents()
Gets the extents of the current cluster, in layout coordinates.
int get_index()
Gets the current byte index. Note that iterating forward by char moves in visual order, not logical order, so indexes may not be sequential. Also, the index may be equal to the length of the text in the layout.
array get_layout_extents()
Obtains the extents of the layout.
GTK2.Pango.LayoutLine get_line()
Gets the current line.
array get_line_extents()
Obtains the extents of the current line.
array get_line_yrange()
Divides the vertical space being iterated over between the lines in the layout, and returns the space belonging to the current line. A line's range includes the line's logical extents, plus half of the spacing above and below the line, if Pango.Layout->set_spacing() has been called to set layout spacing. The y positions are in layout coordinates.
array get_run_extents()
Gets the extents of the current run in layout coordinates.
int next_char()
Moves forward to the next character in visual order. If it was already at the end of the layout, returns false.
int next_cluster()
Moves forward to the next cluster in visual order. If it was already at the end of the layout, returns false.
int next_line()
Moves forward to the start of the next line. If it is already on the last line, returns false.
int next_run()
Moves forward to the next run in visual order. If it was already at the end of the layout, returns false.
| CLASS GTK2.IconInfo |
Contains information found when looking up an icon in an icon theme.
GTK2.IconInfo copy()
Make a copy.
int get_base_size()
Gets the base size for the icon. The base size is a size for the icon that was specified by the icon theme creator. This may be different than the actual size of image; an example of this is small emblem icons that can be attached to a larger icon. These icons will be given the same base size as the larger icons to which they are attached.
GTK2.GdkPixbuf get_builtin_pixbuf()
Gets the built-in image for this icon, if any. To allow GTK2+ to use built-in icon images, you must pass the GTK2.ICON_LOOKUP_USE_BUILTIN to GTK2.IconTheme->lookup_icon().
string get_filename()
Gets the filename for the icon. If the GTK2.ICON_LOOKUP_USE_BUILTIN flag was passed to GTK2.IconTheme->lookup_icon(), there may be no filename if a builtin icon is returned; in this case, you should use get_builtin_pixbuf().
GTK2.GdkPixbuf load_icon()
Renders an icon previously looked up in an icon theme using GTK2.IconTheme->lookup_icon(); the size will be based on the size passed to GTK2.IconTheme->lookup_icon(). Note that the resulting pixbuf may not be exactly this size; an icon theme may have icons that differe slightly from their nominal sizes, and in addition GTK2+ will avoid scaling icons that it considers sufficiently close to the requested size or for which the source image would have to be scaled up too far. (This maintains sharpness.)
| CLASS GTK2.Gnome2CanvasWidget |
Properties: int anchor float height int size-pixels GTK2.Widget widget float width float x float y
inherit Gnome2.CanvasItem : CanvasItem
| CLASS GTK2.Gnome2CanvasBpath |
inherit Gnome2.CanvasShape : CanvasShape
| CLASS GTK2.Calendar |
A calendar widget.
GTK2.Calendar();

GTK2.Calendar()->select_day( 16 );

Properties: int day int month int no-month-change int show-day-names int show-heading int show-week-numbers int year
Signals: day_selected
day_selected_double_click
month_changed
next_month
next_year
prev_month
prev_year
inherit GTK2.Widget : Widget
GTK2.Calendar clear_marks()
Remove all day markers
GTK2.Calendar GTK2.Calendar(mapping|void props)
Create a new calendar widget
GTK2.Calendar freeze()
Suspend all dynamic updating of the widget
mapping get_date()
returns a mapping: ([ "year":year, "month":month, "day":day ])
int get_display_options()
Returns the current display options.
array get_marked_dates()
Returns an array (with 31 elements) with 1es and 0es.
GTK2.Calendar mark_day(int day_of_month)
Mark a day
GTK2.Calendar select_day(int day_of_month)
Select a certain day of the currently selected month
int select_month(int month, int year)
Select the month to be viewed.
GTK2.Calendar set_display_options(int options)
Bitwise or of one or more of CALENDAR_NO_MONTH_CHANGE , CALENDAR_SHOW_DAY_NAMES , CALENDAR_SHOW_HEADING , CALENDAR_SHOW_WEEK_NUMBERS and CALENDAR_WEEK_START_MONDAY .
GTK2.Calendar thaw()
Resume dynamic updating of the widget
GTK2.Calendar unmark_day(int day_of_month)
Unmark a day
| CLASS GTK2.ComboBox |
Properties: int active int add-tearoffs int column-span-column int focus-on-click int has-frame GTK2.TreeModel model int row-span-column int wrap-width
Style properties: int appears-as-list
Signals: changed
inherit GTK2.Bin : Bin
inherit GTK2.CellLayout : CellLayout
inherit GTK2.CellEditable : CellEditable
GTK2.ComboBox append_text(string text)
Appends text to the list of strings stored in this combo box. Note that you can only use this function with combo boxes constructed with GTK2.ComboBox("a string").
GTK2.ComboBox GTK2.ComboBox(GTK2.TreeModel model_or_props)
Create a new ComboBox, either empty or with a model. If a string is passed int instead, it will create a new W(ComboBox) with only text strings. If you do so, you should only manipulate it with the following functions: append_text(), insert_text(), prepend_text(), and remove_text().
int get_active()
Returns the index of the currently active item, or -1 if none. If the model is a non-flat treemodel, and the active item is not an immediate child of the root of the tree, this function returns path_get_indices(path)[0], where path is the GTK2.TreePath of the active item.
GTK2.TreeIter get_active_iter()
Get the current active item.
string get_active_text()
Returns the currently active string. Note that you can only use this function with combo boxes constructed with GTK2.ComboBox("a string").
int get_add_tearoffs()
Gets whether the popup menu has tearoff items.
int get_column_span_column()
Returns the column with column span information.
int get_focus_on_click()
Returns whether the combo box grabs focus when it is clicked with the mouse.
GTK2.TreeModel get_model()
Get the GTK2.TreeModel which is acting as a data source.
int get_row_span_column()
Returns the column with row span information.
int get_wrap_width()
Returns the wrap width which is used to determine the number of columns for the popup menu. If the wrap width is larger than 1, the combo box is in table mode.
GTK2.ComboBox insert_text(int position, string text)
Inserts string at position in the list of strings stored. Note that you can only use this function with combo boxes constructed with GTK2.ComboBox("a string").
GTK2.ComboBox popdown()
Hides the menu or dropdown list.
GTK2.ComboBox popup()
Pops up the menu or dropdown list.
GTK2.ComboBox prepend_text(string text)
Prepends string to the list of strings stored in this combo box. Note that you can only use this function with combo boxes constructed with GTK2.ComboBox("a string").
GTK2.ComboBox remove_text(int position)
Removes the string at position from this combo box. Note that you can only use this function with combo boxes constructed with GTK2.ComboBox("a string").
GTK2.ComboBox set_active(int index_)
Sets the active item.
GTK2.ComboBox set_active_iter(GTK2.TreeIter iter)
Sets the current active item to be the one referenced by iter. iter must correspond to a path of depth one.
GTK2.ComboBox set_add_tearoffs(int setting)
Sets whether the popup menu should have a tearoff menu item.
GTK2.ComboBox set_column_span_column(int column_span)
Sets the column span information. The column span column contains integers which indicate how many columns an item should span.
GTK2.ComboBox set_focus_on_click(int setting)
Sets whether the combo box will grab focus when it is clicked with the mouse.
GTK2.ComboBox set_model(GTK2.TreeModel model)
Sets the model used by this widget. Will unset a previously set model. If no arguments are passed, then it will unset the model.
GTK2.ComboBox set_row_separator_func(function f, mixed user_data)
Sets the row separator function, which is used to determine whether a row should be drawn as a separator. If the row separator function is 0 no separators are drawn. This is the default value.
GTK2.ComboBox set_row_span_column(int row_span)
Sets the column with row span information. The row span column contains integers which indicate how many rows an item should span.
GTK2.ComboBox set_wrap_width(int width)
Sets the wrap width. The wrap width is basically the preferred number of columns when you want the popup to be layed out in a table.
| CLASS GTK2.VScrollbar |
General documentation: See W(Scrollbar)
GTK2.VScrollbar(GTK2.Adjustment())->set_size_request(15,60)
![]()
inherit GTK2.Scrollbar : Scrollbar
GTK2.VScrollbar GTK2.VScrollbar(GTK2.Adjustment pos_or_props)
Used to create a new vscrollbar widget.
| CLASS GTK2.Notebook |
The NoteBook Widget is a collection of 'pages' that overlap each other, each page contains different information. This widget has become more common lately in GUI programming, and it is a good way to show blocks similar information that warrant separation in their display.
GTK2.Notebook()->set_tab_pos(GTK2.POS_LEFT)->append_page(GTK2.Label("Page 1\nContents"),GTK2.Label("Page 1"))->append_page(GTK2.Label(""),GTK2.Label("Page 2"))->append_page(GTK2.Label("Page 3 contents\nare here!"),GTK2.Label("Page 3"))
![]()
GTK2.Notebook()->set_tab_pos(GTK2.POS_TOP)->append_page(GTK2.Label("Page 1\nContents"),GTK2.Label("Page 1"))->append_page(GTK2.Label(""),GTK2.Label("Page 2"))->append_page(GTK2.Label("Page 3 contents\nare here!"),GTK2.Label("Page 3"))

GTK2.Notebook()->set_tab_pos(GTK2.POS_RIGHT)->append_page(GTK2.Label("Page 1\nContents"),GTK2.Label("Page 1"))->append_page(GTK2.Label(""),GTK2.Label("Page 2"))->append_page(GTK2.Label("Page 3 contents\nare here!"),GTK2.Label("Page 3"))->next_page()->next_page()
![]()
Properties: int enable-popup int homogeneous int page int scrollable int show-border int show-tabs int tab-border int tab-hborder int tab-pos int tab-vborder
Child properties: string menu-label int position int tab-expand int tab-fill string tab-label int tab-pack
Style properties: int has-backward-stepper int has-forward-stepper int has-secondary-backward-stepper int has-secondary-forward-stepper
Signals: change_current_page
focus_tab
move_focus_out
select_page
switch_page Called when a different page is selected
inherit GTK2.Container : Container
GTK2.Notebook append_page(GTK2.Widget contents, GTK2.Widget label)
Add a new 'page' to the notebook. The first argument is the contents of the page, the second argument is the label.
GTK2.Notebook append_page_menu(GTK2.Widget contents, GTK2.Widget label, GTK2.Widget menu)
Add a new 'page' to the notebook. The first argument is the contents of the page, the second argument is the label, the third argument is a menu label widget.
GTK2.Notebook GTK2.Notebook(mapping|void props)
Create a W(Notebook) widget with no pages.
int get_current_page()
Returns the index of the currently selected page
GTK2.Widget get_menu_label(GTK2.Widget page)
Return the menu label widget.
string get_menu_label_text(GTK2.Widget child)
Retrieves the text of the menu label for the page containing child.
int get_n_pages()
Get the number of pages.
GTK2.Widget get_nth_page(int index)
Returns the page for the specified index
int get_scrollable()
Returns whether the tab label area has arrows for scrolling.
int get_show_border()
Returns whether a bevel will be drawn around the pages.
int get_show_tabs()
Returns whether the tabs of the notebook are shown.
GTK2.Widget get_tab_label(GTK2.Widget page)
Returns the tab label widget.
string get_tab_label_text(GTK2.Widget child)
Retrieves the text of the tab label for the page containing child.
int get_tab_pos()
Gets the edge at which the tabs are located.
GTK2.Notebook insert_page(GTK2.Widget contents, GTK2.Widget label, int pos)
Insert a page at the specified location, arguments as for append_page, but an aditional integer specifies the location.
GTK2.Notebook insert_page_menu(GTK2.Widget contents, GTK2.Widget label, GTK2.Widget menu, int pos)
Insert a page at the specified location, arguments as for append_page_menu, but an additional integer specifies the location.
GTK2.Notebook next_page()
Go to the next page
int page_num(GTK2.Widget widget)
Returns the index for the specified page.
GTK2.Notebook popup_disable()
Disable the popup menu (set with insert_page_menu).
GTK2.Notebook popup_enable()
Enable the popup menu (set with insert_page_menu).
GTK2.Notebook prepend_page(GTK2.Widget contents, GTK2.Widget label)
Add a page at the end of the list of pages. The first argument is the contents of the page, the second argument is the label.
GTK2.Notebook prepend_page_menu(GTK2.Widget contents, GTK2.Widget label, GTK2.Widget menu)
Add a new 'page' at the end of the list of pages. The first argument is the contents of the page, the second argument is the label, the third argument is a menu label widget.
GTK2.Notebook prev_page()
Go to the previous page
mapping query_tab_label_packing(GTK2.Widget page)
Returns ([ "expand":expandp, "fill":fillp, "pack_type":type ])
GTK2.Notebook remove_page(int pos)
Remove a page.
GTK2.Notebook reorder_child(GTK2.Widget child, int position)
Reorders the page containing child, so that it appears at position.
GTK2.Notebook set_current_page(int pos)
Go to the specified page
GTK2.Notebook set_menu_label(GTK2.Widget child, GTK2.Widget label)
Changes the menu label for the page containing child.
GTK2.Notebook set_menu_label_text(GTK2.Widget child, string label_text)
Creates a new label with label_text sets it as the menu label.
GTK2.Notebook set_scrollable(int scrollablep)
If true, add scrollbars if necessary.
GTK2.Notebook set_show_border(int showborderp)
If true, show the borders around the contents and tabs.
GTK2.Notebook set_show_tabs(int showtabsp)
If supplied with a true value, the tabs will be shown. Otherwise they will not be shown. The user will not be able to select the pages without them, but you can add 'next' and 'previous' buttons to create a wizard-line interface.
GTK2.Notebook set_tab_label(GTK2.Widget child, GTK2.Widget label)
Changes the tab label for child.
GTK2.Notebook set_tab_label_packing(GTK2.Widget child, int expand, int fill, int type)
Sets the packing parameters for the tab label of the page child.
GTK2.Notebook set_tab_label_text(GTK2.Widget child, string title)
Creates a new label and sets it as the tab label for the page containing child.
GTK2.Notebook set_tab_pos(int pos)
Sets the edge at which the tabs for switching pages in the notebook are drawn. One of POS_BOTTOM , POS_LEFT , POS_RIGHT and POS_TOP
| CLASS GTK2.IconView |
GTK2.IconView provides an alternative view on a list model. It displays the model as a grid of icons with labels. Like GTK2.TreeView, it allows to select one or multiple items (depending on the selection mode). In addition to seleciton with the arrow keys, GTK2.IconView supports rubberband selections, which is controlled by dragging the pointer. Properties: int column-spacing int columns int item-width int margin int markup-column GTK2.TreeModel model int orientation int pixbuf-column int row-spacing int selection-mode int spacing int text-column
Style properties: int selection-box-alpha GDK2.Color selection-box-color
Signals: activate_cursor_item
item_activated
move_cursor
select_all
select_cursor_item
selection_changed
set_scroll_adjustments
toggle_cursor_item
unselect_all
inherit GTK2.Container : Container
GTK2.IconView GTK2.IconView(GTK2.TreeModel model_or_props)
Creates a new GTK2.IconView widget Not implemented yet.
int get_column_spacing()
Returns the value of the column-spacing property.
int get_columns()
Returns the value of the columns property.
array get_cursor()
Returns the GTK2.TreePath and GTK2.CellRenderer of the current cursor path and cell. If the cursor isn't currently set, then path will be 0. If no cell currently has focus, then cell will be 0.
array get_item_at_pos(int x, int y)
Finds the path at the point (x,y) relative to widget coordinates. In contrast to get_path_at_pos(), this function also obtains the cell at the specified position.
int get_item_width()
Returns the value of the item-width property.
int get_margin()
Returns the value of the margin property.
int get_markup_column()
Returns the column with markup text.
GTK2.TreeModel get_model()
Gets the model.
int get_orientation()
Returns the value of the orientation property.
GTK2.TreePath get_path_at_pos(int x, int y)
Finds the path at the point(x,y) relative to widget coordinates.
int get_pixbuf_column()
Returns the column with pixbufs.
int get_reorderable()
Retrieves whether the user can reorder the list via drag-and-drop.
int get_row_spacing()
Returns the value of the row-spacing property.
array get_selected_items()
Creates a list of paths of all selected items. Not implemented yet.
int get_selection_mode()
Gets the selection mode.
int get_spacing()
Returns the value of the spacing property
int get_text_column()
Returns the column with text.
array get_visible_range()
Returns the first and last visible path. Note that there may be invisible paths in between.
GTK2.IconView item_activated(GTK2.TreePath path)
Activates the item determined by path.
int path_is_selected(GTK2.TreePath path)
Returns true if the icon pointed to by path is currently selected. If icon does not point to a valid location, false is returned.
GTK2.IconView scroll_to_path(GTK2.TreePath path, int use_align, float row_align, float col_align)
Moves the alignments to the position specified by path. row_align determines where the row is placed, and col_align determines where column is placed. Both are expected to be between 0.0 and 1.0. 0.0 means left/top alignment, 1.0 means right/bottom alignment, 0.5 means center.
If use_align is FALSE, then the alignment arguments are ignored, and the tree does the minimum amount of work to scroll the item onto the screen. This means that the item will be scrolled to the edge closest to its current position. If the item is currently visible on the screen, nothing is done.
This funciton only works if the model is set, and path is a valid row on the model. If the model changes before this icon view is realized, the centered path will be modified to reflect this change.
GTK2.IconView select_all()
Selects all the icons. This widget must have its selection mode set to GTK2.SELECTION_MULTIPLE.
GTK2.IconView select_path(GTK2.TreePath path)
Selects the row at path
GTK2.IconView set_column_spacing(int column_spacing)
Sets the column-spacing property which specifies the space which is inserted between the columns of the icon view.
GTK2.IconView set_columns(int columns)
Sets the columns property which determines in how many columns the icons are arranged. If columns is -1, the number of columns will be chosen automatically to fill the available area.
GTK2.IconView set_cursor(GTK2.TreePath path, GTK2.CellRenderer cell, int|void start_editing)
Sets the current keyboard focus to be at path, and selects it. This is usefull when you want to focus the user's attention on a particular item. If cell is not 0, then focus is given to the cell speicified by it. Additionally, if start_editing is TRUE, then editing should be started in the specified cell.
This function is often followed by grab_focus() in order to give keyboard focus to the widget.
GTK2.IconView set_item_width(int item_width)
Sets the item-width property which specifies the width to use for each item. If it is set to -1, the icon view will automatically determine a suitable item size.
GTK2.IconView set_margin(int margin)
Sets the margin property.
GTK2.IconView set_markup_column(int column)
Sets the column with markup information to be column.
GTK2.IconView set_model(GTK2.TreeModel model)
Sets the model.
GTK2.IconView set_orientation(int orientation)
Sets the orientation property which determines whether the labels are drawn beside the icons instead of below. One of ORIENTATION_HORIZONTAL and ORIENTATION_VERTICAL
GTK2.IconView set_pixbuf_column(int column)
Sets the column with pixbufs to be column.
GTK2.IconView set_reorderable(int setting)
This function is a convenience function to allow you to reorder models. Both GTK2.TreeStore and GTK2.ListStore support this. If setting is TRUE, then the user can reorder the model by dragging and dropping rows. The developer can listen to these changes by connecting to the model's "row-inserted" and "row-deleted" signals.
GTK2.IconView set_row_spacing(int row_spacing)
Sets the row-spacing property which specifies the space which is inserted between the rows of the icon view.
GTK2.IconView set_selection_mode(int mode)
Sets the selection mode. One of SELECTION_BROWSE , SELECTION_MULTIPLE , SELECTION_NONE and SELECTION_SINGLE
GTK2.IconView set_spacing(int spacing)
Sets the spacing property which specifies the space which is inserted between the cells (i.e. the icon and the text) of an item.
GTK2.IconView set_text_column(int column)
Sets the column with text to be column.
GTK2.IconView unselect_all()
Unselects all the icons.
GTK2.IconView unselect_path(GTK2.TreePath path)
Unselects the row at path
| CLASS GTK2.MenuToolButton |
Properties to be notified. GTK2.Menu menu
Signals: show_menu
inherit GTK2.ToolButton : ToolButton
GTK2.MenuToolButton GTK2.MenuToolButton(GTK2.Widget icon, string|void label)
Create a new GTK2.MenuToolButton. If icon is a string, label should be omitted. If it isn't, it will be igrnored. The result will be a button from a stock item, one of STOCK_ABOUT , STOCK_ADD , STOCK_APPLY , STOCK_BOLD , STOCK_CANCEL , STOCK_CDROM , STOCK_CLEAR , STOCK_CLOSE , STOCK_COLOR_PICKER , STOCK_CONNECT , STOCK_CONVERT , STOCK_COPY , STOCK_CUT , STOCK_DELETE , STOCK_DIALOG_AUTHENTICATION , STOCK_DIALOG_ERROR , STOCK_DIALOG_INFO , STOCK_DIALOG_QUESTION , STOCK_DIALOG_WARNING , STOCK_DIRECTORY , STOCK_DISCONNECT , STOCK_DND , STOCK_DND_MULTIPLE , STOCK_EDIT , STOCK_EXECUTE , STOCK_FILE , STOCK_FIND , STOCK_FIND_AND_REPLACE , STOCK_FLOPPY , STOCK_FULLSCREEN , STOCK_GOTO_BOTTOM , STOCK_GOTO_FIRST , STOCK_GOTO_LAST , STOCK_GOTO_TOP , STOCK_GO_BACK , STOCK_GO_DOWN , STOCK_GO_FORWARD , STOCK_GO_UP , STOCK_HARDDISK , STOCK_HELP , STOCK_HOME , STOCK_INDENT , STOCK_INDEX , STOCK_INFO , STOCK_ITALIC , STOCK_JUMP_TO , STOCK_JUSTIFY_CENTER , STOCK_JUSTIFY_FILL , STOCK_JUSTIFY_LEFT , STOCK_JUSTIFY_RIGHT , STOCK_LEAVE_FULLSCREEN , STOCK_MEDIA_FORWARD , STOCK_MEDIA_NEXT , STOCK_MEDIA_PAUSE , STOCK_MEDIA_PLAY , STOCK_MEDIA_PREVIOUS , STOCK_MEDIA_RECORD , STOCK_MEDIA_REWIND , STOCK_MEDIA_STOP , STOCK_MISSING_IMAGE , STOCK_NETWORK , STOCK_NEW , STOCK_NO , STOCK_OK , STOCK_OPEN , STOCK_PASTE , STOCK_PREFERENCES , STOCK_PRINT , STOCK_PRINT_PREVIEW , STOCK_PROPERTIES , STOCK_QUIT , STOCK_REDO , STOCK_REFRESH , STOCK_REMOVE , STOCK_REVERT_TO_SAVED , STOCK_SAVE , STOCK_SAVE_AS , STOCK_SELECT_COLOR , STOCK_SELECT_FONT , STOCK_SORT_ASCENDING , STOCK_SORT_DESCENDING , STOCK_SPELL_CHECK , STOCK_STOP , STOCK_STRIKETHROUGH , STOCK_UNDELETE , STOCK_UNDERLINE , STOCK_UNDO , STOCK_UNINDENT , STOCK_YES , STOCK_ZOOM_100 , STOCK_ZOOM_FIT , STOCK_ZOOM_IN and STOCK_ZOOM_OUT . If icon is a GTK2.Widget, it will be used as the icon, and label will be the label. The label must exist if that is the case.
GTK2.Widget get_menu()
Returns the GTK2.Menu.
GTK2.MenuToolButton set_arrow_tooltip(GTK2.Tooltips tooltips, string tip_text, string tip_private)
Sets the GTK2.Tooltips object to be used for the arrow button which pops up the menu.
GTK2.MenuToolButton set_menu(GTK2.Widget menu)
Sets the GTK2.Menu that is popped up when the user clicks on the arrow.
| CLASS GTK2.GdkDrawable |
The GDK2.Bitmap, GDK2.Window and GDK2.Pixmap classes are all GDK drawables.
This means that you can use the same set of functions to draw in them.
Pixmaps are offscreen drawables. They can be drawn upon with the standard drawing primitives, then copied to another drawable (such as a GDK2.Window) with window->draw_pixmap(), set as the background for a window or widget, or otherwise used to show graphics (in a W(Pixmap), as an example). The depth of a pixmap is the number of bits per pixels. Bitmaps are simply pixmaps with a depth of 1. (That is, they are monochrome bitmaps - each pixel can be either on or off).
Bitmaps are mostly used as masks when drawing pixmaps, or as a shape for a GDK2.Window or a W(Widget)
inherit G.Object : Object
GDK2.Drawable clear(int|void x, int|void y, int|void width, int|void height)
Either clears the rectangle defined by the arguments, of if no arguments are specified, the whole drawable.
GDK2.Drawable copy_area(GTK2.GdkGC gc, int xdest, int ydest, GTK2.Widget source, int xsource, int ysource, int width, int height)
Copies the rectangle defined by xsource,ysource and width,height from the source drawable, and places the results at xdest,ydest in the drawable in which this function is called.
GDK2.Drawable draw_arc(GTK2.GdkGC gc, int filledp, int x1, int y1, int x2, int y2, int angle1, int angle2)
Draws a single circular or elliptical arc. Each arc is specified by a rectangle and two angles. The center of the circle or ellipse is the center of the rectangle, and the major and minor axes are specified by the width and height. Positive angles indicate counterclockwise motion, and negative angles indicate clockwise motion. If the magnitude of angle2 is greater than 360 degrees, it is truncated to 360 degrees.
GDK2.Drawable draw_bitmap(GTK2.GdkGC gc, GTK2.GdkBitmap bitmap, int xsrc, int ysrc, int xdest, int ydest, int width, int height)
Draw a GDK2(Bitmap) in this drawable. NOTE: This drawable must be a bitmap as well. This will be fixed in GTK 1.3
GDK2.Drawable draw_image(GTK2.GdkGC gc, GTK2.GdkImage image, int xsrc, int ysrc, int xdest, int ydest, int width, int height)
Draw the rectangle specified by xsrc,ysrc+width,height from the GDK2(Image) at xdest,ydest in the destination drawable
GDK2.Drawable draw_line(GTK2.GdkGC gc, int x1, int y1, int x2, int y2)
img_begin w = GTK2.DrawingArea()->set_size_request(100,100); delay: g = GDK2.GC(w)->set_foreground( GDK2.Color(255,0,0) ); delay: for(int x = 0; x<10; x++) w->draw_line(g,x*10,0,100-x*10,99); img_end
GDK2.Drawable draw_pixbuf(GTK2.GdkGC gc, GTK2.GdkPixbuf pixbuf, int xsrc, int ysrc, int xdest, int ydest, int width, int height)
Draw a GDK2(Pixbuf) in this drawable.
GDK2.Drawable draw_pixmap(GTK2.GdkGC gc, GTK2.GdkPixmap pixmap, int xsrc, int ysrc, int xdest, int ydest, int width, int height)
Draw the rectangle specified by xsrc,ysrc+width,height from the GDK2(Pixmap) at xdest,ydest in the destination drawable
GDK2.Drawable draw_point(GTK2.GdkGC gc, int x, int y)
img_begin w = GTK2.DrawingArea()->set_size_request(10,10); delay: g = GDK2.GC(w)->set_foreground( GDK2.Color(255,0,0) ); delay: for(int x = 0; x<10; x++) w->draw_point(g, x, x); img_end
GDK2.Drawable draw_rectangle(GTK2.GdkGC gc, int filledp, int x1, int y1, int x2, int y2)
img_begin w = GTK2.DrawingArea()->set_size_request(100,100); delay: g = GDK2.GC(w)->set_foreground( GDK2.Color(255,0,0) ); delay: for(int x = 0; x<10; x++) w->draw_rectangle(g,0,x*10,0,100-x*10,99); img_end img_begin w = GTK2.DrawingArea()->set_size_request(100,100); delay: g = GDK2.GC(w); delay: for(int x = 0; x<30; x++) { delay: g->set_foreground(GDK2.Color(random(255),random(255),random(255)) ); delay: w->draw_rectangle(g,1,x*10,0,100-x*10,99); delay: } img_end
GDK2.Drawable draw_text(GTK2.GdkGC gc, int x, int y, string text)
y is used as the baseline for the text.
mapping get_geometry()
Get width, height position and depth of the drawable as a mapping.
([ "x":xpos, "y":ypos, "width":xsize, "height":ysize, "depth":bits_per_pixel ])
GDK2.Drawable set_background(GTK2.GdkColor to)
Set the background color or image. The argument is either a GDK2.Pixmap or a GDK2.Color object.
int xid()
Return the xwindow id.
int xsize()
Returns the width of the drawable specified in pixels
int ysize()
Returns the height of the drawable specified in pixels
| CLASS GTK2.Hscale |
The GTK2.HScale widget is used to allow the user to select a value using a horizontal slider. A GTK2.Adjustment is used to set the initial value, the lower and upper bounds, and the step and page increments.
See W(Scale) for details
The position to show the current value, and the number of decimal places shown can be set using the parent W(Scale) class's functions.
GTK2.Hscale(GTK2.Adjustment())->set_size_request(300,30)
![]()
inherit GTK2.Scale : Scale
GTK2.Hscale GTK2.Hscale(GTK2.Adjustment settings_or_min_props, float|void max, float|void step)
Used to create a new hscale widget. Either pass an W(Adjustment), or three floats representing min, max, and step values.
| CLASS GTK2.Tooltips |
Tooltips are the messages that appear next to a widget when the mouse pointer is held over it for a short amount of time. They are especially helpful for adding more verbose descriptions of things such as buttons in a toolbar.
An individual tooltip belongs to a group of tooltips. A group is created with a call to GTK2.Tooltips(). Every tooltip in the group can then be turned off with a call to disable() and enabled with enable().
The length of time the user must keep the mouse over a widget before the tip is shown, can be altered with set_delay(). This is set on a 'per group of tooltips' basis.
To assign a tip to a particular W(Widget), set_tip() is used.
The default appearance of all tooltips in a program is determined by the current gtk theme that the user has selected. To change the tooltip appearance manually, use set_colors(). Again, this is per group of tooltips.
inherit GTK2.Data : Data
GTK2.Tooltips GTK2.Tooltips()
Creates an empty group of tooltips. This function initialises a GTK2.Tooltips structure. Without at least one such structure, you can not add tips to your application.
GTK2.Tooltips disable()
Disable this tooltip collection.
GTK2.Tooltips enable()
Enable this tooltip collection.
GTK2.Tooltips force_window()
Realize the tooltip window (as returned from get_gdkwindow())
GTK2.Tooltips set_tip(GTK2.Widget in, string to)
Adds a tooltip containing the message tip_text to the specified W(Widget).
| CLASS GTK2.Bin |
A container that can only contain one child.
inherit GTK2.Container : Container
GTK2.Widget get_child()
Return the child.
| CLASS GTK2.SyntaxTag |
inherit GTK2.SourceTag : SourceTag
GTK2.SyntaxTag GTK2.SyntaxTag(string id, string name, string pattern_start, string pattern_end)
Creates a new syntax tag object with the provided arguments.
| CLASS GTK2.GdkPixbuf |
Properties: int bits-per-sample int colorspace (GdkColorspace) int has-alpha int height int n-channels object pixels int rowstride int width
inherit G.Object : Object
GTK2.GdkPixbuf add_alpha(int substitute_color, int r, int g, int b)
Adds an alpha channel to this pixbuf and returns a copy. If it already has an alpha channel, the channel values are copied from the original; otherwise, the alpha channel is initialized to 255 (full opacity). If substitute_color is true, then the color specified by (r,g,b) will be assigned zero opacity. That is, if you pass (255,255,255) for the substitute color, all white pixels will become fully transparent.
GTK2.GdkPixbuf composite(GTK2.GdkPixbuf dest, int dest_x, int dest_y, int dest_width, int dest_height, float offset_x, float offset_y, float scale_x, float scale_y, int type, int overall_alpha)
Creates a transformation of the source image by scalling by scale_x and scale_y, then translating by offset_x and offset_y. This gives an image in the coordinates of the destination pixbuf. The rectangle (dest_x,dest_y,dest_width,dest_height) is then composited onto the corresponding rectangle of the original destination image. when the destination rectangle contain parts not in the source image, the data at the edges of the source image is replicated to infinity.
GTK2.GdkPixbuf composite_color(GTK2.GdkPixbuf dest, int dest_x, int dest_y, int dest_width, int dest_height, float offset_x, float offset_y, float scale_x, float scale_y, int type, int overall_alpha, int check_x, int check_y, int check_size, int color1, int color2)
Creates a transformation of the source image by scaling by scale_x and scale_y, then translating by offset_x and offset_y, then composites the rectangle (dest_x,dest_y,dest_width,dest_height) of the resulting image with a checkboard of the colors color1 and color2 and renders it onto the destinagion image.
See composite_color_simple() for a simpler variant of this function suitable for many tasks.
GTK2.GdkPixbuf composite_color_simple(int dest_width, int dest_height, int type, int overall_alpha, int check_size, int color1, int color2)
Creates a new W(Pixbuf) by scalling src to dest_width x dest_height and compositing the result with a checkboard of colors color1 and color2.
GTK2.GdkPixbuf copy()
Creates a new GDK2.Pixbuf with a copy of this one.
GTK2.GdkPixbuf copy_area(GTK2.GdkPixbuf dest, int src_x, int src_y, int widt, int height, int dest_x, int dest_y)
Copies a rectangular area from this pixbuf to dest. Conversion of pixbuf formats is done automatically.
GDK2.Pixbuf GTK2.GdkPixbuf(string|mapping options)
Create a GDK2.Pixbuf object. options is either a filename or a mapping of options. options can be:
|
GTK2.GdkPixbuf flip(int horizontal)
Flips a pixbuf horizontally or vertically and returns the result in a new pixbuf.
int get_bits_per_sample()
Queries the number of bits per color sample.
int get_colorspace()
Queries the color space.
int get_has_alpha()
Queries whether a pixbuf has an alpha channel.
int get_height()
Queries the height.
int get_n_channels()
Queries the number of channels.
string get_option(string key)
Looks up key in the list of options that may have been attached to the pixbuf when it was loaded.
string get_pixels()
Returns the pixel data as a string.
int get_rowstride()
Queries the rowstride of a pixbuf, which is the number of bytes between the start of a row and the start of the next row.
int get_width()
Queries the width.
GTK2.GdkPixbuf new_subpixbuf(int src_x, int src_y, int width, int height)
Creates a new pixbuf which represents a sub-region of src. The new pixbuf shares its pixels with the original pixbuf, so writing to one affects both. The new pixbuf holds a reference to this one, so this object will not be finalized until the new pixbuf is finalized.
int put_pixel(int x, int y, int r, int g, int b)
Set pixel to value.
GTK2.GdkBitmap render_threshold_alpha(int src_x, int src_y, int dest_c, int dest_y, int width, int height, int alpha_threshold)
Takes the opacity values in a rectangular portion of a pixbuf and thresholds them to produce a bi-level alpha mask that can be used as a clipping mask for a drawable.
GTK2.GdkPixbuf rotate_simple(int angle)
Rotates a pixbuf by a multiple of 90 degrees, and returns the result in a new pixbuf. angle is either a multiple of 90 degrees (0,90,180,270), or one of GDK_PIXBUF_ROTATE_CLOCKWISE , GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE , GDK_PIXBUF_ROTATE_NONE and GDK_PIXBUF_ROTATE_UPSIDEDOWN , which are merely aliases.
GDK2.Pixbuf saturate_and_pixelate(GTK2.GdkPixbuf dest, float saturation, int pixelate)
Modifes saturation and optionally pixelates this pixbuf, placing the result in dest. The source and dest may be the same pixbuf with no ill effects. If saturation is 1.0 then saturation is not changed. If it's less than 1.0, saturation is reduced (the image is darkened); if greater than 1.0, saturation is increased (the image is brightened). If pixelate is true, then pixels are faded in a checkerboard pattern to create a pixelated image. This pixbuf and dest must have the same image format, size, and rowstride.
GTK2.GdkPixbuf save(string filename, string type, mapping|void options)
Save to a file in format type. "jpeg", "png", "ico", "bmp", are the only valid writable types at this time. Quality is only valid for jpeg images.
GTK2.GdkPixbuf scale(GTK2.GdkPixbuf dest, int dest_x, int dest_y, int dest_width, int dest_height, float offset_x, float offset_y, float scale_x, float scale_y, int type)
Creates a transformation of the source image by scaling by scale_x and scale_y, then translating by offset_x and offset_y, then renders the rectangle (dest_x,dest_y,dest_width,dest_height) of the resulting image onto the destination image replacing the previous contents. Try to use scale_simple() first, this function is the industrial- strength power tool you can fall back to if scale_simple() isn't powerful enough.
GTK2.GdkPixbuf scale_simple(int dest_width, int dest_height, int|void interp_type)
Create a new W(Pixbuf) containing a copy of this W(Pixbuf) scaled to dest_width x dest_height. Leaves this W(Pixbuf) unaffected. intertype should be GDK2.INTERP_NEAREST if you want maximum speed (but when scaling down GDK2.INTERP_NEAREST is usually unusably ugly). The default interp_type should be GDK2.INTERP_BILINEAR which offers reasonable quality and speed. You can scale a sub-portion by create a sub-pixbuf with new_subpixbuf().
int set_alpha(int x, int y, int setting)
Set alpha value.
int set_option(string key, string value)
Attaches a key/value pair as an option. If the key already exists in the list of options, the new value is ignored.
| CLASS GTK2.CellEditable |
GTK2.CellEditable editing_done()
Emits the "editing-done" signal. This signal is a sign for the cell renderer to update its value from the cell.
GTK2.CellEditable remove_widget()
Emits the "remove-widget" signal. This signal is meant to indicate that the cell is finished editing, and the widget may now be destroyed.
GTK2.CellEditable start_editing(GTK2.GdkEvent event)
Begins editing. event is the GDK2.Event that began the editing process. It may be empty, in the instance that editing was initiated through programmatic means.
| CLASS GTK2.Vpaned |
The paned window widgets are useful when you want to divide an area into two parts, with the relative size of the two parts controlled by the user. A groove is drawn between the two portions with a handle that the user can drag to change the ratio. This widgets makes a vertical division
GTK2.Vpaned()->add1(GTK2.Label("Top Side Of Pane"))->add2(GTK2.Label("Bottom"))->set_size_request(100,100)

inherit GTK2.Paned : Paned
GTK2.Vpaned GTK2.Vpaned(mapping|void props)
Create a new W(Vpaned) widget.
| CLASS GTK2.TextMark |
Marks for the text.
inherit G.Object : Object
GTK2.TextBuffer get_buffer()
Gets the buffer this mark is located inside, or empty if the mark is deleted.
int get_deleted()
Returns true if the mark has been removed from its buffer with delete_mark(). Marks can't be used once deleted.
int get_left_gravity()
Determines whether the mark has left gravity.
string get_name()
Returns the mark name; returns empty for anonymous marks.
int get_visible()
Returns true if the mark is visible.
GTK2.TextMark set_visible(int setting)
Sets the visibility of the mark; the insertion point is normally visible, i.e. you can see it as a vertical bar. Also the text widget uses a visible mark to indicate where a drop will occur when dragging-and-dropping text. Most other marks are not visible. Marks are not visible by default.
| CLASS GTK2.Hpaned |
The paned window widgets are useful when you want to divide an area into two parts, with the relative size of the two parts controlled by the user. A groove is drawn between the two portions with a handle that the user can drag to change the ratio. This widgets makes a horizontal division
See W(Paned) for details.
GTK2.Hpaned()->add1(GTK2.Label("Left\nSide\nOf\nPane"))->add2(GTK2.Label("Right\nSide\nOf\nPane"))->set_size_request(100,100)

inherit GTK2.Paned : Paned
GTK2.Hpaned GTK2.Hpaned(mapping|void props)
Create a new W(Hpaned) widget.
| CLASS GTK2.SourceView |
Properties: int auto-indent int highlight-current-line int insert-spaces-instead-of-tabs int margin int show-line-markers int show-line-numbers int show-margin int smart-home-end int tabs-width
Signals: redo
undo
inherit GTK2.TextView : TextView
GTK2.SourceView GTK2.SourceView(GTK2.SourceBuffer buffer)
Create a new W(SourceView). If a buffer isn't specified, an empty default buffer will be created.
int get_auto_indent()
Returns whether auto indentation of text is enabled.
GTK2.SourceStyleScheme get_default()
Gets the default style scheme.
int get_insert_spaces_instead_of_tabs()
Returns whether when inserting a tabulator character it should be replaced by a group of space characters.
int get_margin()
Gets the position of the right margin.
GTK2.GdkPixbuf get_marker_pixbuf(string type)
Gets the pixbuf which is associated with the given type.
int get_show_line_numbers()
Returns whether line markers are displayed beside the text.
int get_show_margin()
Returns whether a margin is displayed.
int get_smart_home_end()
Returns whether HOME and END keys will move to the first/last non-space character of the line before moving to the start/end.
int get_tabs_width()
Returns the width of tabulation in characters.
GTK2.SourceView set_auto_indent(int setting)
If true, auto indentation of text is enabled.
GTK2.SourceView set_insert_spaces_instead_of_tabs(int setting)
If true, any tabulator character inserted is replaced by a group of space characters.
GTK2.SourceView set_margin(int setting)
Sets the position of the right margin in the given view.
GTK2.SourceView set_marker_pixbuf(string type, GTK2.GdkPixbuf pixbuf)
Associates a given pixbuf with a given marker type.
GTK2.SourceView set_show_line_markers(int setting)
If true, line makers will be displayed beside the text.
GTK2.SourceView set_show_line_numbers(int setting)
If true, line numbers will be displayed beside the text.
GTK2.SourceView set_show_margin(int setting)
If true, a margin is displayed.
GTK2.SourceView set_smart_home_end(int setting)
If true, HOME and END keys will move to the first/last non-space character of the line before moving to the start/end.
GTK2.SourceView set_tabs_width(int width)
Sets the width of tabulation in characters.
| CLASS GTK2.TreeSelection |
Selections on a treestore.
Signals: changed
inherit G.Object : Object
int count_selected_rows()
Returns the number of rows that have been selected.
int get_mode()
Gets the selectiom mode.
array get_selected()
Returns a W(TreeITer) with the currently selected node if this selection is set to GTK2.SELECTION_SINGLE or GTK2.SELECTION_BROWSE. Also returns W(TreeModel) as a convenience. This function will not work if you this selection is set to GTK2.SELECTION_MULTIPLE.
array get_selected_rows(GTK2.TreeModel model)
Creates a list of W(TreePath)'s for all selected rows. Additionally, if you are planning on modified the model after calling this function, you may want to convert the returned list into a list of W(TreeRowReference)s. To do this, you can use GTK2.TreeRowReference->create().
GTK2.TreeView get_tree_view()
Returns the tree view associated with this selection.
object get_user_data()
Returns the user data for the selection function.
int iter_is_selected(GTK2.TreeIter iter)
Returns true if the row at iter is currently selected.
int path_is_selected(GTK2.TreePath path)
Returns true if the row pointed to by path is currently selected. If path does not point to a valid location, false is returned.
GTK2.TreeSelection select_all()
Selects all the nodes. This selection must be set to GTK2.SELECTION_MULTIPLE mode.
GTK2.TreeSelection select_iter(GTK2.TreeIter iter)
Selects the specified iterator.
GTK2.TreeSelection select_path(GTK2.TreePath path)
Select the row at path.
GTK2.TreeSelection select_range(GTK2.TreePath start, GTK2.TreePath end)
Selects a range of nodes, determined by start and end inclusive. This selection must be set to GTK2.SELECTION_MULTIPLE mode.
GTK2.TreeSelection set_mode(int type)
Sets the selection mode. If the previous type was GTK2.SELECTION_MULTIPLE, then the anchor is kept selected, if it was previously selected. One of SELECTION_BROWSE , SELECTION_MULTIPLE , SELECTION_NONE and SELECTION_SINGLE .
GTK2.TreeSelection unselect_all()
Unselects all the nodes.
GTK2.TreeSelection unselect_iter(GTK2.TreeIter iter)
Unselects the specified iterator.
GTK2.TreeSelection unselect_path(GTK2.TreePath path)
Unselects the row at path.
GTK2.TreeSelection unselect_range(GTK2.TreePath start, GTK2.TreePath end)
Unselects a range of nodes, determined by start and end inclusive.
| CLASS GTK2.SourceLanguagesManager |
inherit G.Object : Object
GTK2.SourceLanguagesManager GTK2.SourceLanguagesManager()
Create a new language manager.
array get_available_languages()
Gets a list of available languages.
array get_lang_files_dirs()
Gets a list of language files directories.
GTK2.SourceLanguage get_language_from_mime_type(string type)
Gets the GTK2.SourceLanguage which is associated with the given type in the language manager.
GTK2.SourceLanguage get_language_from_name(string name)
Gets the GTK2.SourceLanguage which has this name.
| CLASS GTK2.Gnome2DruidPageEdge |
inherit Gnome2.DruidPage : DruidPage
Gnome2.DruidPageEdge GTK2.Gnome2DruidPageEdge(int position, int|void anti_alias)
Create a new Gnome2.DruidPageEdge, with optional anti-aliasing.
Gnome2.DruidPageEdge set_bg_color(GTK2.GdkColor color)
This will set the background color.
Gnome2.DruidPageEdge set_logo(GTK2.GdkPixbuf logo)
Sets a GDK2.Pixbuf as the logo in the top right corner. If omitted, then no logo will be displayed.
Gnome2.DruidPageEdge set_logo_bg_color(GTK2.GdkColor color)
Sets the color behind the druid page's logo.
Gnome2.DruidPageEdge set_text(string text)
Sets the contents of the text portion.
Gnome2.DruidPageEdge set_text_color(GTK2.GdkColor color)
Sets the color of the text in the body of the page.
Gnome2.DruidPageEdge set_textbox_color(GTK2.GdkColor color)
Sets the color of the background in the main text area of the page.
Gnome2.DruidPageEdge set_title(string title)
Sets the contents of the page's title text.
Gnome2.DruidPageEdge set_title_color(GTK2.GdkColor color)
Sets the color of the title text.
Gnome2.DruidPageEdge set_top_watermark(GTK2.GdkPixbuf watermark)
Sets a GDK2.Pixbuf as the watermark on top of the top strip on the druid. If watermark is omitted, it is reset to the normal color.
Gnome2.DruidPageEdge set_watermark(GTK2.GdkPixbuf watermark)
Sets a GDK2.Pixbuf as the watermark on the left strip on the druid. If watermark is omitted, it is reset to the normal color.
| CLASS GTK2.SourceIter |
inherit GTK2.TextIter : TextIter
array backward_search(string str, int flags, GTK2.TextIter limit)
Same as GTK2.TextIter->backward_search(), but supports case insensitive searching.
int find_matching_bracket()
Tries to match the bracket character currently at this iter with its opening/closing counterpart, and if found moves iter to the position where it was found.
array forward_search(string str, int flags, GTK2.TextIter limit)
Same as GTK2.TextIter->backward_search(), but supports case insensitive searching.
| CLASS GTK2.CellRendererText |
Properties: Pango.AttrList attributes string background GDK2.Color background-gdk int background-set int editable int editable-set int ellipsize int ellipsize-set string family int family-set string font Pango.FontDescription font-desc string foreground GDK2.Color foreground-gdk int foreground-set string language int language-set string markup int rise int rise-set float scale int scale-set int single-paragraph-mode int size float size-points int size-set int stretch PANGO_STRETCH_CONDENSED , PANGO_STRETCH_EXPANDED , PANGO_STRETCH_EXTRA_CONDENSED , PANGO_STRETCH_EXTRA_EXPANDED , PANGO_STRETCH_NORMAL , PANGO_STRETCH_SEMI_CONDENSED , PANGO_STRETCH_SEMI_EXPANDED , PANGO_STRETCH_ULTRA_CONDENSED and PANGO_STRETCH_ULTRA_EXPANDED int stretch-set int strikethrough int strikethrough-set int style PANGO_STYLE_ITALIC , PANGO_STYLE_NORMAL and PANGO_STYLE_OBLIQUE int style-set string text int underline PANGO_UNDERLINE_DOUBLE , PANGO_UNDERLINE_ERROR , PANGO_UNDERLINE_LOW , PANGO_UNDERLINE_NONE and PANGO_UNDERLINE_SINGLE int underline-set int variant PANGO_VARIANT_NORMAL and PANGO_VARIANT_SMALL_CAPS int variant-set int weight int weight-set int width-chars
Signals: edited
inherit GTK2.CellRenderer : CellRenderer
GTK2.CellRendererText GTK2.CellRendererText(mapping|void props)
Creates a new W(CellRendererText). Adjust how text is drawn using object properties. Object properties can be set globally (with G.Object->set()). Also, with W(TreeViewColumn), you can bind a property to a value in a W(TreeModel). For example, you can bind the "text" property on the cell renderer to a string value in the model, thus rendering a different string in each row of the W(TreeView).
GTK2.CellRendererText set_fixed_height_from_font(int number_of_rows)
Sets the height of a renderer to explicitly be determined by the "font" and "y_bad" property set on it. Further changes in these properties do not affect the height, so they must be accompanied by a subsequent call to this function. Using this function is unflexible, and should really only be used if calculating the size of cell is too slow (i.e., a massive number of cells displayed). If number_of_rows is -1, then the fixed height is unset, and the height is determined by the properties again.
| CLASS GTK2.GdkWindow |
a GDK2.Window object.
NOIMG
inherit GDK2.Drawable : Drawable
GDK2.Window change_property(GDK2.Atom property, GDK2.Atom type, int mode, string data)
mode is one of GDK_PROP_MODE_APPEND , GDK_PROP_MODE_PREPEND and GDK_PROP_MODE_REPLACE
array children()
Returns an array of GDK2.Window objects.
GDK2.Window GTK2.GdkWindow(GTK2.GdkWindow parent, mapping|void attributes)
Not for non-experts. I promise.
GDK2.Window delete_property(GDK2.Atom a)
Delete a property.
mapping get_geometry()
Returns ([ "x":xpos, "y":ypos, "width":width, "height":height, "depth":bits_per_pixel ])
mapping get_property(GDK2.Atom atom, int|void offset, int|void delete_when_done)
Returns the value (as a string) of the specified property. The arguments are:
property: The property atom, as an example GDK2.Atom.__SWM_VROOT offset (optional): The starting offset, in elements delete_when_done (optional): If set, the property will be deleted when it has been fetched.
Example usage: Find the 'virtual' root window (many window managers put large windows over the screen)
GDK2.Window root = GTK.root_window();
array maybe=root->children()->
get_property(GDK2.Atom.__SWM_VROOT)-({0});
if(sizeof(maybe))
root=GDK2.Window( maybe[0]->data[0] );
int is_viewable()
Return 1 if the window is mapped.
int is_visible()
Return 1 if the window, or a part of the window, is visible right now.
GDK2.Window lower()
Lower this window if the window manager allows that.
GDK2.Window move_resize(int x, int y, int w, int h)
Move and resize the window in one call.
GDK2.Window raise()
Raise this window if the window manager allows that.
GDK2.Window set_background(GTK2.GdkColor to)
Set the background color or image. The argument is either a GDK2.Pixmap or a GDK2.Color object.
GDK2.Window set_bitmap_cursor(GTK2.GdkBitmap image, GTK2.GdkBitmap mask, GTK2.GdkColor fg, GTK2.GdkColor bg, int xhot, int yhot)
xhot,yhot are the locations of the x and y hotspot relative to the upper left corner of the cursor image.
GDK2.Window set_cursor(int new_cursor)
Change the window cursor.<table border="0" cellpadding="3" cellspacing="0"> CURS(GDK2.Arrow) CURS(GDK2.BasedArrowDown) CURS(GDK2.BasedArrowUp) CURS(GDK2.Boat) CURS(GDK2.Bogosity) CURS(GDK2.BottomLeftCorner) CURS(GDK2.BottomRightCorner) CURS(GDK2.BottomSide) CURS(GDK2.BottomTee) CURS(GDK2.BoxSpiral) CURS(GDK2.CenterPtr) CURS(GDK2.Circle) CURS(GDK2.Clock) CURS(GDK2.CoffeeMug) CURS(GDK2.Cross) CURS(GDK2.CrossReverse) CURS(GDK2.Crosshair) CURS(GDK2.DiamondCross) CURS(GDK2.Dot) CURS(GDK2.Dotbox) CURS(GDK2.DoubleArrow) CURS(GDK2.DraftLarge) CURS(GDK2.DraftSmall) CURS(GDK2.DrapedBox) CURS(GDK2.Exchange) CURS(GDK2.Fleur) CURS(GDK2.Gobbler) CURS(GDK2.Gumby) CURS(GDK2.Hand1) CURS(GDK2.Hand2) CURS(GDK2.Heart) CURS(GDK2.Icon) CURS(GDK2.IronCross) CURS(GDK2.LeftPtr) CURS(GDK2.LeftSide) CURS(GDK2.LeftTee) CURS(GDK2.Leftbutton) CURS(GDK2.LlAngle) CURS(GDK2.LrAngle) CURS(GDK2.Man) CURS(GDK2.Middlebutton) CURS(GDK2.Mouse) CURS(GDK2.Pencil) CURS(GDK2.Pirate) CURS(GDK2.Plus) CURS(GDK2.QuestionArrow) CURS(GDK2.RightPtr) CURS(GDK2.RightSide) CURS(GDK2.RightTee) CURS(GDK2.Rightbutton) CURS(GDK2.RtlLogo) CURS(GDK2.Sailboat) CURS(GDK2.SbDownArrow) CURS(GDK2.SbHDoubleArrow) CURS(GDK2.SbLeftArrow) CURS(GDK2.SbRightArrow) CURS(GDK2.SbUpArrow) CURS(GDK2.SbVDoubleArrow) CURS(GDK2.Shuttle) CURS(GDK2.Sizing) CURS(GDK2.Spider) CURS(GDK2.Spraycan) CURS(GDK2.Star) CURS(GDK2.Target) CURS(GDK2.Tcross) CURS(GDK2.TopLeftArrow) CURS(GDK2.TopLeftCorner) CURS(GDK2.TopRightCorner) CURS(GDK2.TopSide) CURS(GDK2.TopTee) CURS(GDK2.Trek) CURS(GDK2.UlAngle) CURS(GDK2.Umbrella) CURS(GDK2.UrAngle) CURS(GDK2.Watch) CURS(GDK2.Xterm) </table>
GDK2.Window set_events(int events)
events is a bitwise or of one or more of the following constants: GDK2.ExposureMask, GDK2.PointerMotionMask, GDK2.PointerMotion_HINTMask, GDK2.ButtonMotionMask, GDK2.Button1MotionMask, GDK2.Button2MotionMask, GDK2.Button3MotionMask, GDK2.ButtonPressMask, GDK2.ButtonReleaseMask, GDK2.KeyPressMask, GDK2.KeyReleaseMask, GDK2.EnterNotifyMask, GDK2.LeaveNotifyMask, GDK2.FocusChangeMask, GDK2.StructureMask, GDK2.PropertyChangeMask, GDK2.VisibilityNotifyMask, GDK2.ProximityInMask, GDK2.ProximityOutMask and GDK2.AllEventsMask
GDK2.Window set_icon(GTK2.GdkPixmap pixmap, GTK2.GdkBitmap mask, GTK2.GdkWindow window)
Set the icon to the specified image (with mask) or the specified GDK2.Window. It is up to the window manager to display the icon. Most window manager handles window and pixmap icons, but only a few can handle the mask argument. If you want a shaped icon, the only safe bet is a shaped window.
GDK2.Window set_icon_name(string name)
Set the icon name to the specified string.
GDK2.Window shape_combine_mask(GTK2.GdkBitmap mask, int xoffset, int yoffset)
Set the shape of the widget, or, rather, it's window, to that of the supplied bitmap.
| CLASS GTK2.G.Object |
The base object. All GDK and GTK classes inherit from this. The Pango classes also inherit from this class.
Signals: notify
G.Object accel_groups_activate(int accel_key, int accel_mods)
Finds the first accelerator in an GTK.AccelGroup attached to this object that matches accel_key and accel_mods, and activates that accelerator.
mixed get_property(string property)
Get a property.
int new_signal(string name, array types, string return_type)
Create a new signal.
G.Object notify(string property)
Emits a "notify" signal for the named property on the object.
G.Object set_property(string property, mixed value)
Set a property on a G.Object (and any derived types) to value.
G.Object signal_block(int signal_id)
Temporarily block a signal handler. No signals will be received while the handler is blocked. See signal_connect() for more info.
int signal_connect(string signal, function callback, mixed|void callback_arg, string|void detail)
int signal_connect(string signal, function callback, mixed ... args) Connect a signal to a pike function. The function will be called with the last argument to this function as it's first argument (defaults to 0), the second argument is always the widget, and any other arguments are the ones supplied by GTK.
The return value of this function can be used to remove a signal with signal_disconnect(), and block and unblock the signal with signal_block() and signal_unblock().
G.Object signal_disconnect(int signal_id)
Remove a signal formerly added by signal_connect. The argument is the return value of signal_connect(). See signal_connect() for more info.
G.Object signal_emit(string signal_name, string|void detail)
Send the current named signal.
G.Object signal_unblock(int signal_id)
Unblock a formerly blocked signal handler. See signal_block() and signal_connect() for more info.
| CLASS GTK2.Gnome2DateEdit |
The GnomeDateEdit widget provides a way to enter dates and times
with a helper calendar to let the user select the date.
GTK2.Gnome2DateEdit(time(),1,1);
![]()
GTK2.Gnome2DateEdit(time(),0,1);
![]()
Properties: int dateedit-flags int initial-time int lower-hour int time int upper-hour
Signals: date_changed
time_changed
inherit GTK2.Hbox : Hbox
Gnome2.DateEdit GTK2.Gnome2DateEdit(int the_time, int show_time, int use_24_format)
Creates a new GnomeDateEdit widget which can be used to provide an easy to use way for entering dates and times.
int get_flags()
Get the flags.
int get_initial_time()
Queries the initial time that was set using set_time() or during creation.
int get_time()
Return the time entered in the widget.
Gnome2.DateEdit set_flags(int flags)
Bitwise or of GNOME_DATE_EDIT_24_HR , GNOME_DATE_EDIT_SHOW_TIME and GNOME_DATE_EDIT_WEEK_STARTS_ON_MONDAY .
Gnome2.DateEdit set_popup_range(int low_hour, int up_hour)
Sets the range of times that will be provide by the time popup selectors.
Gnome2.DateEdit set_time(int the_time)
Changes the displayed date and time in the GnomeDateEdit widget to be the one represented by the_time.
| CLASS GTK2.TreeIter |
TreeIter.
GTK2.TreeIter copy()
Creates a copy of this tree iter.
| CLASS GTK2.Vscale |
The GTK2.HScale widget is used to allow the user to select a value using a horizontal slider. A GTK2.Adjustment is used to set the initial value, the lower and upper bounds, and the step and page increments.
See W(Scale) for details
The position to show the current value, and the number of decimal places shown can be set using the parent W(Scale) class's functions.
GTK2.Vscale(GTK2.Adjustment())->set_size_request(300,30)
![]()
inherit GTK2.Scale : Scale
GTK2.Vscale GTK2.Vscale(GTK2.Adjustment settings_or_min_props, float|void max, float|void step)
Used to create a new hscale widget. Either pass an W(Adjustment), or three floats representing min, max, and step values.
| CLASS GTK2.CellRendererCombo |
Properties: int has-entry GTK2.TreeModel model int text-column
inherit GTK2.CellRendererText : CellRendererText
GTK2.CellRendererCombo GTK2.CellRendererCombo(mapping|void props)
Creates a new W(CellRendererCombo).
| CLASS GTK2.FileChooserButton |
Properties: GTK2.FileChooserDialog dialog string title int width-chars
inherit GTK2.Hbox : Hbox
GTK2.FileChooserButton GTK2.FileChooserButton(string|mapping title_or_props, int|void action)
Create a new file-selecting button widget. action is one of FILE_CHOOSER_ACTION_CREATE_FOLDER , FILE_CHOOSER_ACTION_OPEN , FILE_CHOOSER_ACTION_SAVE and FILE_CHOOSER_ACTION_SELECT_FOLDER
string get_title()
Retrieves the title of the browse dialog.
int get_width_chars()
Retrieves the width in characters of the button widget's entry and/or label.
GTK2.FileChooserButton set_title(string title)
Modifies the title of the browse dialog.
GTK2.FileChooserButton set_width_chars(int n_chars)
Sets the width (in characters) that the button will use.
| CLASS GTK2.ToggleToolButton |
A ToolItem containing a toggle button.
Signals: toggled
inherit GTK2.ToolButton : ToolButton
GTK2.ToggleToolButton GTK2.ToggleToolButton(string|mapping stock_id)
Creates a new toggle tool button, with or without a stock id.
int get_active()
Returns the status of the toggle tool button, true if it is pressed in and false if it isn't.
GTK2.ToggleToolButton set_active(int is_active)
Sets the status of the toggle tool button. Set to true if you want the button to be pressed in, and false to raise it. This causes the toggled signal to be emitted.
| CLASS GTK2.Gnome2CanvasItem |
This is the base class for all canvas items. Canvas items are the drawing elements of a Gnome2.Canvas. Example items include lines, ellipses, polygons, images, text, curves, and even arbitary GTK+ widgets.
Properties: Gnome2.CanvasItem parent
Signals: event
inherit GTK2.Object : Object
| CLASS GTK2.Invisible |
An invisible container, useful, eh? :) Properties: GDK2.Screen screen
inherit GTK2.Widget : Widget
GTK2.Invisible GTK2.Invisible(mapping|void props)
Create a new invisible widget
GTK2.GdkScreen get_screen()
Gets the screen associated with this object.
GTK2.Invisible set_screen(GTK2.GdkScreen screen)
Sets the screen where this object will be displayed.
| CLASS GTK2.ScrolledWindow |
Scrolled windows are used to create a scrollable area with another widget insite it. You may insert any type of widget into a scrolled window, and it will be accessible regardless of the size by using the scrollbars.
GTK2.ScrolledWindow(GTK2.Adjustment(),GTK2.Adjustment())->add(GTK2.Label("A small label"))->set_policy(GTK2.POLICY_AUTOMATIC,GTK2.POLICY_AUTOMATIC)
![]()
GTK2.ScrolledWindow(GTK2.Adjustment(),GTK2.Adjustment())->add(GTK2.Label("A small label"))->set_policy(GTK2.POLICY_AUTOMATIC,GTK2.POLICY_AUTOMATIC)
![]()
GTK2.ScrolledWindow(GTK2.Adjustment(),GTK2.Adjustment())->add(GTK2.Label("A small label"))

GTK2.ScrolledWindow(GTK2.Adjustment(),GTK2.Adjustment())->add(GTK2.Label("a ver huge label"))

Properties: GTK2.Adjustment hadjustment int hscrollbar-policy int shadow-type GTK2.Adjustment vadjustment int vscrollbar-policy int window-placement
Style properties: int scrollbar-spacing
Signals: move_focus_out
scroll_child
inherit GTK2.Bin : Bin
GTK2.ScrolledWindow add(GTK2.Widget victim)
Add a widget to this container. This is equivalent to the C-GTK function gtk_scrolled_window_add_with_viewport or gtk_container_add, depending on whether or not the child supports the set_scroll_adjustments signal.
What this means in practice is that you do not have to care about this at all, it's all handled automatically.
GTK2.ScrolledWindow GTK2.ScrolledWindow(GTK2.Adjustment hadjustment_or_props, GTK2.Adjustment vadjustments)
The two adjustments are most commonly set to 0.
GTK2.Adjustment get_hadjustment()
Get the horizontal adjustment.
GTK2.HScrollbar get_hscrollbar()
Returns the horizontal scrollbar.
int get_placement()
Gets the placement of the scrollbars.
mapping get_policy()
Returns the current policy values for the horizontal and vertical scrollbars. ([ "h-policy": horizontal policy, "v-policy": vertical policy ]);
int get_shadow_type()
Gets the shadow type.
GTK2.Adjustment get_vadjustment()
Get the vertical adjustment.
GTK2.VScrollbar get_vscrollbar()
Returns the vertical scrollbar.
GTK2.ScrolledWindow set_hadjustment(GTK2.Adjustment hadjustment)
Set the horizontal adjustment object.
GTK2.ScrolledWindow set_placement(int window_placement)
The location of the window relative to the scrollbars. One of CORNER_BOTTOM_LEFT , CORNER_BOTTOM_RIGHT , CORNER_TOP_LEFT and CORNER_TOP_RIGHT
GTK2.ScrolledWindow set_policy(int xpolicy, int ypolicy)
Vertical and horizontal policy. Both are one of POLICY_ALWAYS , POLICY_AUTOMATIC and POLICY_NEVER
GTK2.ScrolledWindow set_shadow_type(int type)
Changes the type of shadow drawn around the contents. One of SHADOW_ETCHED_IN , SHADOW_ETCHED_OUT , SHADOW_IN , SHADOW_NONE and SHADOW_OUT
GTK2.ScrolledWindow set_vadjustment(GTK2.Adjustment vadjustment)
Set the vertical adjustment object.
| CLASS GTK2.Paned |
GTK2.Paned is the base class for widgets with two panes, arranged either horizontally (W(HPaned)) or vertically (W(VPaned)). Child widgets are added to the panes of the widget with pack1() and pack2(). The division beween the two children is set by default from the size requests of the children, but it can be adjusted by the user.
A paned widget draws a separator between the two child widgets and a small handle that the user can drag to adjust the division. It does not draw any relief around the children or around the separator. (The space in which the separator is called the gutter). Often, it is useful to put each child inside a W(Frame) with the shadow type set to GTK2.ShadowIn so that the gutter appears as a ridge.
Each child has two options that can be set, resize and shrink. If resize is true, then when the GTK2.Paned is resized, that child will expand or shrink along with the paned widget. If shrink is true, then when that child can be made smaller than it's requisition by the user. Setting shrink to 0 allows the application to set a minimum size. If resize is false for both children, then this is treated as if resize is true for both children.
The application can set the position of the slider as if it were set by the user, by calling set_position().
Properties: int max-position int min-position int position int position-set
Child properties: int resize int shrink
Style properties: int handle-size
Signals: accept_position
cancel_position
cycle_child_focus
cycle_handle_focus
move_handle
toggle_handle_focus
inherit GTK2.Container : Container
GTK2.Paned add1(GTK2.Widget left_or_top)
Set the left or topmost item. This is equivalent to pack1(left_or_top,0,1)
GTK2.Paned add2(GTK2.Widget right_or_bottom)
Set the right or bottommost item This is equivalent to pack2(left_or_top,0,1)
GTK2.Widget get_child1()
Obtains the first child of the paned widget.
GTK2.Widget get_child2()
Obtains the second child of the paned widget.
int get_position()
Obtains the position of the divider between the two panes.
GTK2.Paned pack1(GTK2.Widget widget, int resize, int shrink)
Add a child to the top or left pane.
GTK2.Paned pack2(GTK2.Widget widget, int resize, int shrink)
Add a child to the bottom or right pane.
GTK2.Paned set_position(int position)
Set the position of the separator, as if set by the user. If position is negative, the remembered position is forgotten, and the division is recomputed from the the requisitions of the children.
| CLASS GTK2.IconFactory |
Icon factory, for holding icon sets.
inherit G.Object : Object
GTK2.IconFactory add(string stock_id, GTK2.IconSet icon_set)
Adds the given icon_set to the icon factory, under the name of stock_id. stock_id should be namespaced for your application, e.g. "myapp-whatever-icon". Normally applications create a GTK2.IconFactory, then add it to the list of default factories with add_default(). Then they pass the stock_id to widgets such as GTK2.Image to display the icon. Themes can provide an icon with the same name (such as "myapp-whatever-icon") to override your application's default icons. If an icon already existed in this factory for stock_id, it is unreferenced and replaced with the new icon_set.
GTK2.IconFactory add_default()
Adds an icon factory to the list of icon factories search by GTK2.Style->lookup_icon_set(). This means that, for example, GTK2.Image->create("stock-id") will be able to find icons in factory. There will normally be an icon factory added for each library or application that comes with icons. The default icon factories can be overridden by themes.
GTK2.IconFactory GTK2.IconFactory()
Creates a new GTK2.IconFactory. An icon factory manages a collection of GTK2.IconSets; a GTK2.IconSet manages a set of variants of a particular icon (i.e. a GTK2.IconSet contains variants for different sizes and widget states). Icons in an icon factory are named by a stock ID, which is a simple string identifying the icon. Each GTK2.Style has a list of GTK2.IconFactorys derived from the current theme; those icon factories are consulted first when searching for an icon. If the theme doesn't set a particular icon, GTK2+ looks for the icon in a list of default icon factories, maintained by add_default() and remove_default(). Applications with icons should add a default icon factory with their icons, which will allow themes to override the icons for the application.
GTK2.IconSet lookup(string stock_id)
Looks up stock_id in the icon factory, returning an icon set if found, otherwise 0. For display to the user, you should use GTK2.Style->lookup_icon_set() on the GTK2.Style for the widget that will display the icon, instead of using this function directly, so that themes are taken into account.
GTK2.IconSet lookup_default(string stock_id)
Looks for an icon in the list of default icon factories. For display to the user, you should use GTK2.Style->lookup_icon_set() on the GTK2.Style for the widget that will display the icon, instead of using this function directly, so that themes are taken into account.
GTK2.IconFactory remove_default()
Removes an icon factory from the list of default icon factories.
| CLASS GTK2.FileChooserWidget |
File chooser widget that can be embedded in other widgets.
GTK2.FileChooserWidget(GTK2.FILE_CHOOSER_ACTION_OPEN);

inherit GTK2.Vbox : Vbox
inherit GTK2.FileChooser : FileChooser
GTK2.FileChooserWidget GTK2.FileChooserWidget(int|mapping action_or_props)
Create a new file chooser widget. action is one of FILE_CHOOSER_ACTION_CREATE_FOLDER , FILE_CHOOSER_ACTION_OPEN , FILE_CHOOSER_ACTION_SAVE and FILE_CHOOSER_ACTION_SELECT_FOLDER
| CLASS GTK2.ListStore |
A list-like data structure that can be used with W(TreeView).
inherit G.Object : Object
inherit GTK2.TreeModel : TreeModel
inherit GTK2.TreeSortable : TreeSortable
inherit GTK2.TreeDragSource : TreeDragSource
inherit GTK2.TreeDragDest : TreeDragDest
GTK2.TreeIter append()
Append a new row.
GTK2.ListStore clear()
Removes all rows.
GTK2.ListStore GTK2.ListStore(array types)
Create a new list store with as many columns as there are items in the array. A type is either a string representing a type name, such as "int" or "float", or an actual widget. If it is a widget, the column in question should be a widget of the same type that you would like this column to represent.
GTK2.TreeIter insert(int position)
Insert a row at position. If parent is valid, will create as child, otherwise at top level. If position is larger than then number of rows at that level, it will be added to the end of the list. iter will be changed to point to the new row.
GTK2.TreeIter insert_after(GTK2.TreeIter sibling)
Insert a new row after sibling. If sibling is 0, then the row will be prepended to parent's children. If parent and sibling are both 0, then the row will be prepended to the toplevel.
GTK2.TreeIter insert_before(GTK2.TreeIter sibling)
Insert a row before sibling. If sibling is 0, then the row will be appended to parent's children. If parent and sibling are 0, then the row will be appended to the toplevel.
GTK2.ListStore move_after(GTK2.TreeIter iter, GTK2.TreeIter position)
Moves iter to after position. These should be at the same level. This only works if the store is unsorted. If position is omitted, iter will be moved to the start of the level.
GTK2.ListStore move_before(GTK2.TreeIter iter, GTK2.TreeIter position)
Moves iter to before position. These should be at the same level. This only works if the store is unsorted. If position is omitted, iter will be moved to the end of the level.
GTK2.TreeIter prepend()
Prepend a new row.
GTK2.ListStore remove(GTK2.TreeIter iter)
Remove iter. iter is set to the next valid row at that level, or invalidated if it was the last one.
GTK2.ListStore set_row(GTK2.TreeIter iter, array values)
Set the data in an entire row.
GTK2.ListStore set_value(GTK2.TreeIter iter, int column, mixed value)
Set the data in the cell specified by iter and column.
GTK2.ListStore swap(GTK2.TreeIter a, GTK2.TreeIter b)
Swap 2 rows. Only works if this store is unsorted.
| CLASS GTK2.Gnome2Canvas |
Gnome2.Canvas is an engine for structured graphics that offers a rich imaging model, high performance rendering, and a powerful, high level API. It offers a choice of two rendering back-ends, one based on Xlib for extremely fast display, and another based on Libart, a sophisticated, antialiased, alpha-compositing engine. This widget can be used for flexible display of graphics and for creating interactive user interface elements.
A Gnome2.Canvas widget contains one or more Gnome2.CanvasItem objects. Items consist of graphing elements like lines, ellipses, polygons, images, text, and curves. These items are organized using Gnome2.CanvasGroup objects, which are themselves derived from Gnome2.CanvasItem. Since a group is an item it can be contained within other groups, forming a tree of canvas items. Certain operations, like translating and scaling, can be performed on all items in a group. See http://developer.gnome.org/doc/API/2.0/libgnomecanvas/GnomeCanvas.html for more information. Properties: int aa
Signals: draw_background
render_background
inherit GTK2.Layout : Layout
array c2w(int cx, int cy)
Converts canvas pixel coordinates to world coordinates.
Gnome2.Canvas GTK2.Gnome2Canvas(int|void anti_alias)
Create a new Gnome2.Canvas widget. Set anti_alias to true to create a canvas in antialias mode.
int get_center_scroll_region()
Returns whether the canvas is set to center the scrolling region in the window if the former is smaller than the canvas' allocation.
GTK2.GdkColor get_color(string|void spec)
Allocates a color based on the specified X color specification. An omitted or empty string is considered transparent.
int get_color_pixel(int rgba)
Allocates a color from the RGBA value passed into this function. The alpha opacity value is discarded, since normal X colors do not support it.
int get_dither()
Returns the type of dithering used to render an antialiased canvas.
GTK2.Gnome2CanvasItem get_item_at(float x, float y)
Looks for the item that is under the specified position, which must be specified in world coordinates.
array get_scroll_offsets()
Queries the scrolling offsets of a canvas. The values are returned in canvas pixel units.
mapping get_scroll_region()
Queries the scrolling region of a canvas.
GTK2.Gnome2CanvasGroup root()
Queries the root group.
Gnome2.Canvas scroll_to(int cx, int cy)
Makes a canvas scroll to the specified offsets, given in canvas pixel units. The canvas will adjust the view so that it is not outside the scrolling region. This function is typically not used, as it is better to hook scrollbars to the canvas layout's scrolling adjustments.
Gnome2.Canvas set_center_scroll_region(int setting)
When the scrolling region of the canvas is smaller than the canvas window, e.g. the allocation of the canvas, it can be either centered on the window or simply made to be on the upper-left corner on the window.
Gnome2.Canvas set_dither(int dither)
Controls the dithered rendering for antialiased canvases. The value of dither should be GDK2.RgbDitherNone, GDK2.RgbDitherNormal, or GDK2.RgbDitherMax. The default canvas setting is GDK2.RgbDitherNormal.
Gnome2.Canvas set_pixels_per_unit(float n)
Sets the zooming factor of a canvas by specifying the number of pixels that correspond to one canvas unit.
The anchor point for zooming, i.e. the point that stays fixed and all others zoom inwards or outwards from it, depends on whether the canvas is set to center the scrolling region or not. You can contorl this using the set_center_scroll_region() function. If the canvas is set to center the scroll region, then the center of the canvas window is used as the anchor point for zooming. Otherwise, the upper-left corner of the canvas window is used as the anchor point.
Gnome2.Canvas set_scroll_region(float x1, float y1, float x2, float y2)
Sets the scrolling region of a canvas to the specified rectangle. The canvas will then be able to scroll only within this region. The view of the canvas is adjusted as appropriate to display as much of the new region as possible.
array w2c(float wx, float wy)
Converts world coordinates into canvas pixel coordinates.
array w2c_affine()
Gets the affine transform that converts from world coordinates to canvas pixel coordinates.
array w2c_d(float wx, float wy)
Converts world coordinates into canvas pixel coordinates. This version returns coordinates in floating point coordinates, for greater precision.
array window_to_world(float winx, float winy)
Converts window-relative coordinates into world coordinates. You can use this when you need to convert mouse coordinates into world coordinates, for example.
array world_to_window(float worldx, float worldy)
Converts world coordinates into window-relative coordinates.
| CLASS GTK2.Arrow |
An arrow pointing in one of four directions. The 'etched' shadow
types does not work.
GTK2.Arrow(GTK2.ARROW_UP, GTK2.SHADOW_OUT)
![]()
GTK2.Arrow(GTK2.ARROW_LEFT, GTK2.SHADOW_IN)
![]()
GTK2.Arrow(GTK2.ARROW_RIGHT, GTK2.SHADOW_IN)
![]()
GTK2.Arrow(GTK2.ARROW_DOWN, GTK2.SHADOW_OUT)
![]()
Properties: int arrow-type ARROW_DOWN , ARROW_LEFT , ARROW_RIGHT and ARROW_UP int shadow-type SHADOW_ETCHED_IN , SHADOW_ETCHED_OUT , SHADOW_IN , SHADOW_NONE and SHADOW_OUT
inherit GTK2.Misc : Misc
GTK2.Arrow GTK2.Arrow(int|mapping arrow_type_or_props, int|void shadow_type)
First argument is one of ARROW_DOWN , ARROW_LEFT , ARROW_RIGHT and ARROW_UP , second one of SHADOW_ETCHED_IN , SHADOW_ETCHED_OUT , SHADOW_IN , SHADOW_NONE and SHADOW_OUT .
GTK2.Arrow set(int arrow_type, int shadow_type)
First argument is one of ARROW_DOWN , ARROW_LEFT , ARROW_RIGHT and ARROW_UP , second one of SHADOW_ETCHED_IN , SHADOW_ETCHED_OUT , SHADOW_IN , SHADOW_NONE and SHADOW_OUT .
| CLASS GTK2.Gnome2Href |
This widget is a GtkButton button that contains a URL. When clicked it invokes the configured browser for the URL you provided.
GTK2.Gnome2Href( "http://www.gnome.org", "GNOME Web Site" )
![]()
GTK2.Gnome2Href( "http://www.gnome.org" )
![]()
Properties: string text string url
Style properties: GDK.Color link-color
inherit GTK2.Button : Button
Gnome2.Href GTK2.Gnome2Href(string url, string|void label)
Created a GNOME href object, a label widget with a clickable action and an associated URL. If label is set to 0, url is used as the label.
string get_text()
Returns the contents of the label widget used to display the link text.
string get_url()
Return the url
Gnome2.Href set_text(string text)
Sets the internal label widget text (used to display a URL's link text) to the given value.
Gnome2.Href set_url(string url)
Sets the internal URL
| CLASS GTK2.Gnome2CanvasGroup |
inherit Gnome2.CanvasItem : CanvasItem
| CLASS GTK2.Gnome2CanvasRE |
Properties: float x1 float x2 float y1 float y2
inherit Gnome2.CanvasShape : CanvasShape
| CLASS GTK2.SourceBuffer |
Text buffer object for GTK2.SourceView
Properties: int check-brackets int escape-char int highlight GTK2.SourceLanguage language int max-undo-levels
Signals: can_redo
can_undo
highlight_updated
marker_updated
inherit GTK2.TextBuffer : TextBuffer
GTK2.SourceBuffer begin_not_undoable_action()
Marks the beginning of a not undoable action on the buffer, disabling the undo manager. Typically you would call this function before initially setting the contents of the buffer (e.g. when loading a file in a text editor).
You may nest begin_no_undoable_action()/end_not_undoable_action() blocks.
int can_redo()
Determines whether a source buffer can redo the last action.
int can_undo()
Determines whether a source buffer can undo the last action.
GTK2.SourceBuffer GTK2.SourceBuffer(GTK2.SourceTagTable table_or_lang)
Creates a new source buffer. If table_or_lang is a GTK2.SourceLanguage, it will create a buffer using the highlighting patterns of that language. If it is a GTK2.SourceTagTable, it will use that table, otherwise it will be a new source buffer with a new tag table.
GTK2.SourceMarker create_marker(string name, string type, GTK2.TextIter where)
Creates a marker in the buffer of type type. A marker is semantically very similar to a GTK2.TextMark, except it has a type which is used by the GTK2.SourceView displaying the buffer to show a pixmap on the left margin, at the line the marker is in. Becuase of this, a marker is generally associated to a line and not a character position. Markers are also accessible through a position or range in the buffer.
Markers are implemented using GTK2.TextMark, so all characteristics and restrictions to marks apply to markers too. These include life cycle issues and "mark-set" and "mark-deleted" signal emissions.
Like a GTK2.TextMark, a GTK2.SourceMarker can be anonymous if the passed name is 0.
Markers always have left gravity and are moved to the beginning of the line when the users deletes the line they were in. Also, if the user deletes a region of text which contained lines with markers, those are deleted.
Typical uses for a marker are bookmarks, breakpoints, current executing instruction indication in a source file, etc.
GTK2.SourceBuffer delete_marker(GTK2.SourceMarker marker)
Deletes marker from the source buffer. The same conditions as for GTK2.TextMark apply here.
GTK2.SourceBuffer end_not_undoable_action()
Marks the end of a not undoable action on the buffer. When the last not undoable block is closed through a call to this function, the list of undo actions is cleared and the undo manager is re-enabled.
int get_check_brackets()
Determines whether bracket match highlighting is activated.
int get_escape_char()
Determines the escaping character used by the source buffer highlighting engine.
GTK2.SourceMarker get_first_marker()
Returns the first (nearest to the top of the buffer) marker.
int get_highlight()
Determines whether text highlighting is activated in the source buffer.
GTK2.TextIter get_iter_at_marker(GTK2.SourceMarker marker)
Returns a GTK2.TextIter at marker.
GTK2.SourceLanguage get_language()
Determines the GTK2.SourceLanguage used by the buffer.
GTK2.SourceMarker get_last_marker()
Returns the last (nearest to the bottom of the buffer) marker.
GTK2.SourceMarker get_marker(string name)
Looks up the GTK2.SourceMarker named name, or returns 0 if it doesn't exist.
array get_markers_in_region(GTK2.TextIter begin, GTK2.TextIter end)
Returns an ordered (by position) list of GTK2.SourceMarker objects inside the region delimited by the GTK2.TextIters begin and end. The iters may be in any order.
int get_max_undo_levels()
Determines the number of undo levels the buffer will track for buffer edits.
GTK2.SourceMarker get_next_marker(GTK2.TextIter iter)
Returns the nearest marker to the right of iter. If there are multiple markers at the same position, this function will always return the first one (from the internal linked list), even if starting the search exactly at its location. You can get the others using next().
GTK2.SourceMarker get_prev_marker(GTK2.TextIter iter)
Returns the nearest marker to the left of iter. If there are multiple markers at the same position, this function will always return the last one (from the internal linked list), even if starting the search exactly at its location. You can get the others using prev().
GTK2.SourceBuffer move_marker(GTK2.SourceMarker marker, GTK2.TextIter where)
Moves marker to the new location.
GTK2.SourceBuffer redo()
Redoes the last undo operation. Use can_redo() to check whether a call to this function will have any effect.
GTK2.SourceBuffer set_bracket_match_style(mapping style)
Sets the style used for highlighting matching brackets. <code> ([ "default": boolean, "mask": int, "foreground": GDK2.Color, "background": GDK2.Color, "italic": boolean, "bold": boolean, "underline": boolean, "strikethrough": boolean ]); </code>
GTK2.SourceBuffer set_check_brackets(int setting)
Controls the bracket match highlighting function in the buffer. If activated, when you position your cursor over a bracket character (a parenthesis, a square bracket, etc.) the matching opening or closing bracket character will be highlighted. You can specify the style with the set_bracket_match_style() function.
GTK2.SourceBuffer set_escape_char(int escape_char)
Sets the escape character to be used by the highlighting engine.
When performing the initial analysis, the engine will discard a matching syntax pattern if it's prefixed with an odd number of escape characters. This allows for example to correctly highlight strings with escaped quotes embedded.
This setting affects only syntax patterns.
GTK2.SourceBuffer set_highlight(int setting)
Controls whether text is highlighted in the buffer. If setting is true, the text will be highlighted according to the patterns installed in the buffer (either set with set_language() or by adding individual GTK2.SourceTag tags to the buffer's tag table). Otherwise, any current highlighted text will be restored to the default buffer style.
Tags not of GTK2.SourceTag type will not be removed by this option, and normal GTK2.TextTag priority settings apply when highlighting is enabled.
If not using a GTK2.SourceLanguage for setting the highlighting patterns in the buffer, it is recommended for performance reasons that you add all the GTK2.SourceTag tags with highlighting disabled and enable it when finished.
GTK2.SourceBuffer set_language(GTK2.SourceLanguage lang)
Sets the source language the source buffer will use, adding GTK2.SourceTag tags with the language's patterns and setting the escape character with set_escape_char(). Note that this will remove any GTK2.SourceTag tags currently in the buffer's tag table.
GTK2.SourceBuffer set_max_undo_levels(int setting)
Sets the number of undo levels for user actions the buffer will track. If the number of user actions exceeds the limit set by this funcction, older actions will be discarded.
A new action is started whenever the function begin_user_action() is called. In general, this happens whenever the user presses any key which modifies the buffer, but the undo manager will try to merge similar consecutive actions, such as multiple character insertions into one action. But, inserting a newline does start a new action.
GTK2.SourceBuffer undo()
Undoes the last user action which modified the buffer. Use can_undo() to check whether a call to this function will have any effect.
Actions are defined as groups of operations between a call to GTK2.TextBuffer->begin_user_action() and GTK2.TextBuffer->end_user_action(), or sequences of similar edits (inserts or deletes) on the same line.
| CLASS GTK2.ToggleAction |
Properties int draw-as-radio
Signals: toggled
inherit GTK2.Action : Action
GTK2.ToggleAction GTK2.ToggleAction(string|mapping name_or_props, string|void label, string|void tooltip, string|void stock_id)
Creates a new GTK2.ToggleAction object.
int get_active()
Returns the checked state.
int get_draw_as_radio()
Returns whether the action should have proxies like a radio action.
GTK2.ToggleAction set_active(int setting)
Sets the checked state.
GTK2.ToggleAction set_draw_as_radio(int setting)
Sets whether the action should have proxies like a radio action.
GTK2.ToggleAction toggled()
Emits the "toggled" signal.
| CLASS GTK2.IconSource |
Iconsource.
GTK2.IconSource GTK2.IconSource()
Creates a new GTK2.IconSource. A GTK2.IconSource contains a GDK2.Pixbuf (or image filename) that serves as the base image for one or more of the icons in a GTK2.IconSet, along with a specification for which icons in the icon set will be based on that pixbuf or image file. An icon set contains a set of icons that represent "the same" logical concept in different states, different global text directions, and different sizes.
So for example a web browser's "Back to Previous Page" icon might point in a different direction in Hebrew and in English; it might look different when insensitive; and it might change size depending on toolbar mode small/large icons). So a single icon set would contain all those variants of the icon. GTK2.IconSet contains a list of GTK2.IconSource from which it can derive specific icon variants in the set.
In the simplest case, GTK2.IconSet contains one source pixbuf from which it derives all variants. The convenience function GTK2.IconSet->create(pixbuf) handles this case; if you only have one source pixbuf, just use that function.
If you want to use a different base pixbuf for different icon variants, you create multiple icon sources, mark which variants they'll be used to create, and add them to the icon set with GTK2.IconSet->add_source().
By default, the icon source has all parameters wildcarded. That is, the icon source will be used as the base icon for any desired text direction, widget state, or icon size.
int get_direction()
Obtains the text direction this icon source applies to. The return value is only useful/meaningful if the text direction is not wildcarded.
int get_direction_wildcarded()
Gets the value set by set_direction_wildcarded().
string get_filename()
Retrieves the source filename, or empty.
string get_icon_name()
Retrieves the source icon name, or empty.
GTK2.GdkPixbuf get_pixbuf()
Retrieves the source pixbuf, or 0. In addition, if a filename source is in use, this function in some cases will return the pixbuf loaded from the filename. This is, for example, true for the GTK2.IconSource passed to the GTK2.Style->render_icon() virtual function.
int get_size()
Obtains the icon size this source applies to. The return value is only useful/meaningful if the icon size is not wildcarded.
int get_size_wildcarded()
Gets the value set by set_size_wildcarded().
int get_state()
Obtains the widget state this icon source applies to. The return value is only useful/meaningful if the widget state is not wildcarded.
int get_state_wildcarded()
Gets the value set by set_state_wildcarded().
GTK2.IconSource set_direction(int dir)
Sets the text direction this icon source is intended to be used with.
Setting the text direction on an icon source makes no difference if the text direction is wildcarded. Therefore, you should usually call set_direction_wildcarded() to un-wildcard it in addition to calling this function.
GTK2.IconSource set_direction_wildcarded(int setting)
If the text direction is wildcarded, this source can be used as the base image for an icon in any text direction. If the text direction is not wildcarded, then the text direction the icon source applies to should be set with set_direction(), and the icon source will only be used with that text direction.
GTK2.IconSet prefers non-wildcarded sources (exact matches) over wildcarded sources, and will use an exact match when possible.
GTK2.IconSource set_filename(string filename)
Sets the name of an image file to use as a base image when creating icon variants for GTK2.IconSet. The filename must be absolute.
GTK2.IconSource set_icon_name(string name)
Sets the name of an icon to look up in the current icon theme to use as a base image.
GTK2.IconSource set_pixbuf(GTK2.GdkPixbuf pixbuf)
Sets a pixbuf to use as a base image.
GTK2.IconSource set_size(int size)
Sets the icon size this icon source is intended to be with.
GTK2.IconSource set_size_wildcarded(int setting)
If the icon size is wildcarded, this source can be used as the base image for an icon of any size. If the size is not wildcarded, then the size the source applies to should be set with set_size() and the icon source will only be used with that specific size.
GTK2.IconSource set_state(int state)
Sets the widget state this icon source is intended to be used with.
GTK2.IconSource set_state_wildcarded(int setting)
If the widget state is wildcarded, this source can be used as the base image for an icon in any state. If the widget state is not wildcarded, then the state the source applies to should be set with set_state() and the icon source will only be used with that specific state.
| CLASS GTK2.MenuShell |
A GTK2.MenuShell is the abstract base class used to derive the W(Menu) and W(MenuBar) subclasses.
A GTK2.MenuShell is a container of W(MenuItem) objects arranged in a list which can be navigated, selected, and activated by the user to perform application functions. A W(MenuItem) can have a submenu associated with it, allowing for nested hierarchical menus.
Signals: activate_current An action signal that activates the current menu item within the menu shell.
cancel An action signal which cancels the selection within the menu shell. Causes the selection-done signal to be emitted.
cycle_focus
deactivate This signal is emitted when a menu shell is deactivated.
move_current An action signal which moves the current menu item in the direction specified.
selection_done This signal is emitted when a selection has been completed within a menu shell.
inherit GTK2.Container : Container
GTK2.MenuShell activate_item(GTK2.Widget menu_item, int force_deactivate)
Activates the menu item within the menu shell.
GTK2.MenuShell append(GTK2.Widget what)
Adds a new W(MenuItem) to the end of the menu shell's item list. Same as 'add'.
GTK2.MenuShell cancel()
Cancels the selection within the menu shell.
GTK2.MenuShell deactivate()
Deactivates the menu shell. Typically this results in the menu shell being erased from the screen.
GTK2.MenuShell deselect()
Deselects the currently selected item from the menu shell, if any.
array get_children()
This function returns all children of the menushell as an array.
int get_take_focus()
Returns TRUE if the menu shell will take the keyboard focus on popup.
GTK2.MenuShell insert(GTK2.Widget what, int where)
Add a widget after the specified location
GTK2.MenuShell prepend(GTK2.Widget what)
Add a menu item to the start of the widget (for a menu: top, for a bar: left)
GTK2.MenuShell select_first(int search_sensitive)
Select the first visible or selectable child of the menu shell; don't select tearoff items unless the only item is a tearoff item.
GTK2.MenuShell select_item(GTK2.Widget menuitem)
Selects the menu item from the menu shell.
GTK2.MenuShell set_take_focus(int setting)
If setting is TRUE (the default), the menu shell will take the keyboard focus so that it will receive all keyboard events which is needed to enable keyboard navigation in menus.
| CLASS GTK2.StringTag |
inherit GTK2.SourceTag : SourceTag
GTK2.StringTag GTK2.StringTag(string id, string name, string pattern_start, string pattern_end, int end_at_line_end)
Creates a new string tag object with the provided arguments.
| CLASS GTK2.ProgressBar |
A simple progress bar. Useful when you are doing things that take a long
time. Try to always have an 'abort' button whenever it makes sence.
GTK2.ProgressBar()->set_fraction(0.1)
![]()
GTK2.ProgressBar()->set_property("show_text", 1)->set_fraction(0.3)
![]()
GTK2.ProgressBar()->set_fraction(0.6)
![]()
GTK2.ProgressBar()->set_fraction(1.0)
![]()
Properties: int discrete-blocks int ellipsize float fraction int orientation PROGRESS_BOTTOM_TO_TOP , PROGRESS_CONTINUOUS , PROGRESS_DISCRETE , PROGRESS_LEFT_TO_RIGHT , PROGRESS_RIGHT_TO_LEFT and PROGRESS_TOP_TO_BOTTOM float pulse-step string text
inherit GTK2.Progress : Progress
GTK2.ProgressBar GTK2.ProgressBar(mapping|void props)
Create a new progress bar. The default values are: Min 0.0, max 1.0, current 0.0
int get_ellipsize()
Returns the ellipsizing position of the progressbar.
float get_fraction()
Returns the current fraction of the task that's been completed.
int get_orientation()
Retrieves the current progress bar orientation.
float get_pulse_step()
Retrieves the pulse step.
string get_text()
Retrieves the text displayed superimposed on the progress bar, if any.
GTK2.ProgressBar pulse()
Indicates that some progress is made, but you don't know how much. Causes the progress bar to enter "activity mode", where a block bounces back and forth. Each call to pulse() causes the block to move by a little bit (the amount of movement per pulse is determined by set_pulse_step()).
GTK2.ProgressBar set_ellipsize(int mode)
Sets the mode used to ellipsize (add an ellipsis: "...") the text if there is not enough space to render the entire string. One of .
GTK2.ProgressBar set_fraction(float fraction)
Causes the progress bar to "fill in" the given fraction of the bar. The fraction should be between 0.0 and 1.0, inclusive.
GTK2.ProgressBar set_orientation(int style)
Causes the progress bar to switch to a different orientation (left-to-right, right-to-left, top-to-bottom, or bottom-to-top). One of PROGRESS_BOTTOM_TO_TOP , PROGRESS_CONTINUOUS , PROGRESS_DISCRETE , PROGRESS_LEFT_TO_RIGHT , PROGRESS_RIGHT_TO_LEFT and PROGRESS_TOP_TO_BOTTOM .
GTK2.ProgressBar set_pulse_step(float fraction)
Sets the fraction of total progress bar length to move the bouncing block for each call to pulse().
GTK2.ProgressBar set_text(string text)
Causes the given text to appear superimposed on the progress bar.
| CLASS GTK2.ActionGroup |
Actions are organized into groups. An action group is essentially a map from names to GTK2.Action objects.
All actions that would make sense to use in a particular context should be in a single group. Multiple action groups may be used for a particular user interface. In fact, it is expected that most non-trivial applications will make use of multiple groups. For example, in an application that can edit multiple documents, one group holding global actions (e.g. quit, about, new), and one group per document holding actions that act on that document (eg. save, cut/copy/paste, etc). Each window's menus would be constructed from a combination of two action groups.
Accelerators are handled by the GTK2+ accelerator map. All actions are assigned an accelerator path (which normally has the form <Actions>/group-name/action-name) and a shortcut is associated with this accelerator path. All menuitems and toolitems take on this accelerator path. The GTK2+ accelerator map code makes sure that the correct shortcut is displayed next to the menu item. Properties: string name int sensitive int visible
Signals: connect_proxy
disconnect_proxy
post_activate
pre_activate
inherit G.Object : Object
GTK2.ActionGroup add_action(GTK2.Action action, string|void accelerator)
Adds an action object to the action group and sets up the accelerator.
If accelerator is omitted, attempts to use the accelerator associated with the stock_id of the action.
Accel paths are set to <Actions>/group-name/action-name.
GTK2.ActionGroup add_actions(array entries)
This is a convenience function to create a number of actions and add them to the action group.
The "activate" signals of the actions are connect to the callbacks and their accel paths are set to <Actions>/group-name/action-name.
Mapping is: ([ "name": string, "stock_id": string, "label": string, "accelerator": string, "tooltip": string, "callback": function(callback) "data": mixed ]);
GTK2.ActionGroup add_radio_actions(array entries, function cb, mixed user_data)
This is a convenience routine to create a group of radio actions and add them to the action group.
Mapping is: ([ "name": string, "stock_id": string, "label": string, "accelerator": string, "tooltip": string, "value": int ]);
GTK2.ActionGroup add_toggle_actions(array entries)
This is a convenience function to create a number of toggle actions and add them to the action group.
Mapping is: ([ "name": string, "stock_id": string, "label": string, "accelerator": string, "tooltip": string, "callback": function(callback), "data": mixed, "is_active": int ]);
GTK2.ActionGroup GTK2.ActionGroup(string|mapping name_or_props)
Creates a new GTK2.ActionGroup object. The name of the action group is used when associating keybindings with the actions.
GTK2.Action get_action(string name)
Looks up an action in the action group by name.
string get_name()
Gets the name of the action group.
int get_sensitive()
Returns true if the group is sensitive. The constituent actions can only be logically sensitive if they are sensitive and their group is sensitive.
int get_visible()
Returns true if the group is visible. The constituent actions can only be logically visible if they are visible and their group is visible.
array list_actions()
Lists the actions in the action group.
GTK2.ActionGroup remove_action(GTK2.Action action)
Removes an action object.
GTK2.ActionGroup set_sensitive(int setting)
Changes the sensitivity.
GTK2.ActionGroup set_visible(int setting)
Changes the visibility.
| CLASS GTK2.Box |
A box is a container that can contain more than one child. The basic 'Box' class cannot be instantiated, it is a virtual class that only defines some common 'Box' functions shared with all other Box widgets. Properties: int homogeneous int spacing
Child properties: int expand int fill int pack-type int padding int position
inherit GTK2.Container : Container
int get_homogeneous()
Returns whether the box is homogeneous.
int get_spacing()
Gets the spacing.
GTK2.Box pack_end(GTK2.Widget widget, int expandp, int fillp, int padding)
Pack from the right (or bottom) of the box. Arguments are widget, expand, fill, paddingb widget, expand, fill, padding
GTK2.Box pack_end_defaults(GTK2.Widget widget)
The argument is the widget to add.
GTK2.Box pack_start(GTK2.Widget widget, int expandp, int fillp, int padding)
Pack from the left (or top) of the box. Argument are widget, expand, fill, padding pack(widget,1,1,0) is equivalent to 'add' or 'pack_start_defaults'
GTK2.Box pack_start_defaults(GTK2.Widget widget)
The argument is the widget to add. This function is equivalent to 'add'
mapping query_child_packing(GTK2.Widget child)
Return a mapping: ([ "expand":expandp, "fill":fillp, "padding":paddingp, "type":type ])
GTK2.Box reorder_child(GTK2.Widget child, int new_position)
Move widget to pos, pos is an integer, between 0 and sizeof(box->children())-1
GTK2.Box set_child_packing(GTK2.Widget child_widget, int expandp, int fillp, int padding, int pack_type)
widget, expand, fill, padding, pack_type. If exand is true, the widget will be expanded when the box is resized. If 'fill' is true, the widget will be resized to fill up all available space. Padding is the amount of padding to use, and pack_type is one of PACK_END and PACK_START .
You can emulate pack_start and pack_end with add and set_child_packing.
GTK2.Box set_homogeneous(int homogeneousp)
If true, all widgets in the box will get exactly the same amount of space
GTK2.Box set_spacing(int spacing)
This is the amount of spacing (in pixels) inserted beween all widgets
| CLASS GTK2.TreeView |
Properties: int enable-search GTK2.TreeViewColumn expander-column int fixed-height-mode GTK2.Adjustment hadjustment int headers-clickable int headers-visible int hover-expand int hover-selection GTK2.TreeModel model int reorderable int rules-hint int search-column GTK2.Adjustment vadjustment
Style properties: int allow-rules GDK2.Color even-row-color int expander-size int horizontal-separator int indent-expanders GDK2.Color odd-row-color int vertical-separator
Signals: columns_changed
cursor_changed
expand_collapse_cursor_row
move_cursor
row_activated
row_collapsed
row_expanded
select_all
select_cursor_parent
select_cursor_row
set_scroll_adjustments
start_interactive_search
test_collapse_row
test_expand_row
toggle_cursor_row
unselect_all
inherit GTK2.Container : Container
GTK2.TreeView append_column(GTK2.TreeViewColumn column)
Appends column to the list of columns. If this tree view has "fixed_height" mode enabled, then column must have its "sizing" property set to be GTK2.TREE_VIEW_COLUMN_FIXED.
GTK2.TreeView collapse_all()
Recursively collapses all visible, expanded nodes.
int collapse_row(GTK2.TreePath path)
Collapses a row (hides its child rows, if they exist).
GTK2.TreeView columns_autosize()
Resizes all columns to their optimal width. Only works after the treeview has been realized.
GTK2.TreeView GTK2.TreeView(GTK2.TreeModel model_or_props)
Create a new W(TreeView), with or without a default model.
GTK2.TreeView expand_all()
Recursively expands all nodes.
int expand_row(GTK2.TreePath path, int open_all)
Opens the row so its children are visible.
GTK2.TreeView expand_to_path(GTK2.TreePath path)
Expands the row at path. This will also expand all parent rows of path as necessary.
GTK2.GdkRectangle get_background_area(GTK2.TreePath path, GTK2.TreeViewColumn column)
Similar to get_cell_area(). The returned rectangle is equivalent to the background_area passed to GTK2.CellRenderer->render(). These background area tiles to cover the entire tree window (except for the area used for header buttons). Contrast with get_cell_area(), which returns only the cell itself, excluding surrounding borders and the tree expander area.
GTK2.GdkWindow get_bin_window()
Returns the window that this view renders to. This is used primarily to compare to event->window to confirm that the event on this view is on the right window.
GTK2.GdkRectangle get_cell_area(GTK2.TreePath path, GTK2.TreeViewColumn column)
Fills the bounding rectangle in tree window coordinates for the cell at the row specified by path and the column specified by column. If path is omitted or 0, or points to a path not currently displayed, the y and height fields of the rectangle will be 0. If column is omitted, the x and width fields will be o. The sum of all cell rects does not cover the entire tree; there are extra pixels in between rows, for example. The returned rectangle is equivalent to the cell_area passed to GTK2.CellRenderer->render(). This function is only valid if the view is realized.
GTK2.TreeViewColumn get_column(int n)
Gets the W(TreeViewColumn) at the given position.
array get_columns()
Returns an array of all the W(TreeViewColumn)'s current in the view.
mapping get_cursor()
Returns the current path and focus column. If the cursor isn't currently set, then "path" will be 0. If no column currently has focus, then "focus_column" will be 0. Returns ([ "path": GTK2.TreePath, "column": GTK2.TreeViewColumn ]);
int get_enable_search()
Returns whether or not the tree allows to start interactive searching by typing in text.
GTK2.TreeViewColumn get_expander_column()
Returns the column that is the current expander column. This column has the expander arrow drawn next to it.
GTK2.Adjustment get_hadjustment()
Gets the W(Adjustment) currently being used for the horizontal aspect.
int get_headers_visible()
Returns true if the headers are visible.
GTK2.TreeModel get_model()
Returns the model this TreeView is based on.
mapping get_path_at_pos(int x, int y)
Finds the path at the point (x,y) relative to widget coordinates. That is, x and y are relative to an events coordinates. x and y must come from an event on the view only where event->window==get_bin(). It is primarily for things like popup menus. Returns GTK2.TreePath, GTK2.TreeViewColumn, and cell_x and cell_y, which are the coordinates relative to the cell background (i.e. the background_area passed to GTK2.CellRenderer->render()). This function is only meaningful if the widget is realized.
int get_reorderable()
Retrieves whether the user can reorder the tree via drag-and-drop.
int get_rules_hint()
Gets the setting set by set_rules_hint().
int get_search_column()
Gets the column searched on by the interactive search code.
GTK2.TreeSelection get_selection()
Gets the W(TreeSelection) associated with this TreeView.
GTK2.Adjustment get_vadjustment()
Gets the W(Adjustment) currently being used for the vertical aspect.
array get_visible_range()
Returns the first and last visible path. Note that there may be invisible paths in between.
GTK2.GdkRectangle get_visible_rect()
Returns a GDK2.Rectangle with the currently-visible region of the buffer, in tree coordinates. Conver to widget coordinates with tree_to_widget_coords(). Tree coordinates start at 0,0 for row 0 of the tree, and cover the entire scrollable area of the tree.
int insert_column(GTK2.TreeViewColumn column, int position)
This inserts the column at position. If position is -1, then the column is inserted at the end. If this tree view has "fixed_height" mode enabled, then column must have its "sizing property set to GTK2.TREE_VIEW_COLUMN_FIXED.
GTK2.TreeView move_column_after(GTK2.TreeViewColumn column, GTK2.TreeViewColumn base)
Moves column to be after base. If base is omitted, then column is placed in the first position.
int remove_column(GTK2.TreeViewColumn column)
Removes column.
GTK2.TreeView row_activated(GTK2.TreePath path, GTK2.TreeViewColumn column)
Activates the cell determined by path and column.
int row_expanded(GTK2.TreePath path)
Returns true if the node pointed to by path is expanded.
GTK2.TreeView scroll_to_cell(GTK2.TreePath path, GTK2.TreeViewColumn column, float|void row_align, float|void col_align)
Moves the alignments of the view to the position specified by column and path. If column is 0, then no horizontal scrolling occurs. Likewise, if path is 0, no vertical scrolling occurs. At a minimum, one of column or path needs to be non-zero. row_align determines where the row is placed, and col_align determines where column is placed. Both are expected to be between 0.0 and 1.0. 0.0 means left/top alignment, 1.0 means right/bottom alignment, 0.5 means center.
If row_align exists, then col_align must exist, otherwise neither will be used. If neither are used, the tree does the minimum amount of work to scroll the cell onto the screen. This means that the cell will be scrolled to the edge closest to its current position. If the cell is currently visible on the screen, nothing is done.
This function only works if the model is set, and path is a valid row on the model. If the model changes before the view is realized, the centered path will be modifed to reflect this change.
GTK2.TreeView scroll_to_point(int x, int y)
Scrolls the tree view such that the top-left corner of the visible area is x,y, where x and y are specified in tree window coordinates. The view must be realized before this function is called. If it isn't, you probably want to be using scroll_to_cell().
If either x or y are -1, then that direction isn't scrolled.
GTK2.TreeView set_cursor(GTK2.TreePath path, GTK2.TreeViewColumn focus_column, int|void start_editing)
Sets the current keyboard focus to be at path, and selects it. This is useful when you want to focus the user's attention on a particular row. If focus_column is present, then focus is given to the column specified by it. Additionally, if focus_column is specified, and start_editing is true, then editing should be started in the specified cell. This function is often followed by grab_focus() in order to give keyboard focus to the widget. Please note that editing can only happen when the widget is realized.
GTK2.TreeView set_cursor_on_cell(GTK2.TreePath path, GTK2.TreeViewColumn focus_column, int|void start_editing, GTK2.CellRenderer focus_cell)
Sets the current keyboard focus to be at path, and selects it. This is useful when you want to focus the user's attention on a particular row. If focus_column is present, then focus is given to the column specified by it. If focus_column and focus_cell are present, and focus_column contains 2 or more editable or activatable cells, then focus is given to the cell specified by focus_cell. Additionally, if focus_column is specified, and start_editing is true, then editing should be started in the specified cell. This function is often followed by grab_focus() in order to give keyboard focus to the widget. Please note that editing can only happen when the widget is realized.
GTK2.TreeView set_enable_search(int enable_search)
If enable_search is set, then the user can type in text to search through the tree interactively (this is sometimes called "typeahead find").
Note that even if this is false, the user can still initiate a search using the "start-interactive-search" key binding.
GTK2.TreeView set_expander_column(GTK2.TreeViewColumn column)
Sets the column to draw the expander arrow at. It must be in the view. If column is omitted, then the expander arrow is always at the first visible column.
GTK2.TreeView set_hadjustment(GTK2.Adjustment hadj)
Sets the W(Adjustment) for the current horizontal aspect.
GTK2.TreeView set_headers_clickable(int setting)
Allow the column title buttons to be clicked.
GTK2.TreeView set_headers_visible(int headers_visible)
Sets the visibility state of the headers.
GTK2.TreeView set_model(GTK2.TreeModel model)
Sets the model. If this TreeView already has a model set, it will remove it before setting the new model.
GTK2.TreeView set_reorderable(int reorderable)
This function is a convenience function to allow you to reorder models. If reorderable is true, then the user can reorder the model by dragging and dropping rows. The developer can listen to these changes by connecting to the model's "row-inserted" and "row-deleted" signals.
This function does not give you any degree of control over the order -- any reordering is allowed. If more control is needed, you should probably handle drag and drop manually.
GTK2.TreeView set_rules_hint(int setting)
This function tells GTK2+ that the user interface for your application requires users to read across tree rows and associate cells with one another. By default, GTK2+ will then render the tree with alternating row colors. Do not use it just because you prefer the appearance of the ruled tree; that's a question for the theme. Some themes will draw tree rows in alternating colors even when rules are turned off, and users who prefer that appearance all the time can choose those themes. You should call this function only as a semantic hint to the theme engine that your tree makes alternating colors usefull from a functional standpoint (since it has lots of columns, generally).
GTK2.TreeView set_search_column(int column)
Sets column as the column where the interactive search code should search in.
If the sort column is set, users can use the "start-interactive-search" key binding to bring up search popup. The enable-search property controls whether simply typing text will also start an interactive search.
Note that column refers to a column of the model.
GTK2.TreeView set_vadjustment(GTK2.Adjustment vadj)
Sets the W(Adjustment) for the current vertical aspect.
mapping tree_to_widget_coords(int tx, int ty)
Converts tree coordinates (coordinates in full scrollable area of the tree) to widget coordinates.
mapping widget_to_tree_coords(int wx, int wy)
converts widget coordinates to coordinates for the tree window (the full scrollable area of the tree).
| CLASS GTK2.Fixed |
A fixed container is a container that keeps it's children at fixed locations and give them fixed sizes, both given in pixels.
Example:
GTK2.Fixed()->put(GTK2.Label("100,100"), 100, 100)->put(GTK2.Label("0,0"), 0, 0)->set_size_request(150,115)

Child properties: int x int y
inherit GTK2.Container : Container
GTK2.Fixed GTK2.Fixed(mapping|void props)
Create a new fixed widget
array get_children()
Get a list of the children and their x,y positions.
int get_has_window()
Gets whether GTK2.Fixed has its own GDK2.Window.
GTK2.Fixed move(GTK2.Widget widget, int new_xpos, int new_ypos)
Move the widget to new_xpos,new_ypos from it's old location.
GTK2.Fixed put(GTK2.Widget widget, int x, int y)
Place the widget at xpos,ypos.
GTK2.Fixed set_has_window(int has_window)
Sets wither a GTK2.Fixed widget is created with a separate GDK2.Window for the window or now.
| CLASS GTK2.Item |
This class is inherited by all 'item' type of widgets.
Signals: deselect
select
toggle
inherit GTK2.Bin : Bin
GTK2.Item deselect()
Emulate a 'deselect' event.
GTK2.Item select()
Emulate a 'select' event.
GTK2.Item toggle()
Emulate a 'toggle' event.
| CLASS GTK2.Gnome2DruidPage |
This widget is a virtual widget to define the interface to a druid page. It's descendants are placed in a W(Gnome2.Druid) widget.
Signals: back
cancel
finish
next
prepare
inherit GTK2.Bin : Bin
int back()
This will emit the "back" signal for that particular page.
int cancel()
This will emit the "cancel" signal for that particular page.
Gnome2.DruidPage GTK2.Gnome2DruidPage()
Creates a new Gnome2.DruidPage.
Gnome2.DruidPage finish()
This emits the "finish" signal for the page.
int next()
This will emit the "next" signal for that particular page. It is called by gnome-druid exclusviely. It is expected that non-linear Druid's will override this signal and return true if it handles changing pages.
Gnome2.DruidPage prepare()
This emits the "prepare" signal for the page. It is called by gnome-druid exclusively. This function is called immediately prior to a druid page being show so that it can "prepare" for display.
| CLASS GTK2.Range |
The category of range widgets includes the ubiquitous scrollbar widget and the less common "scale" widget. Though these two types of widgets are generally used for different purposes, they are quite similar in function and implementation. All range widgets share a set of common graphic elements, each of which has its own X window and receives events. They all contain a "trough" and a "slider" (what is sometimes called a "thumbwheel" in other GUI environments). Dragging the slider with the pointer moves it back and forth within the trough, while clicking in the trough advances the slider towards the location of the click, either completely, or by a designated amount, depending on which mouse button is used.
As mentioned in the W(Adjustment) page, all range widgets are associated with an adjustment object, from which they calculate the length of the slider and its position within the trough. When the user manipulates the slider, the range widget will change the value of the adjustment.
All of the GTK range widgets react to mouse clicks in more or less the same way. Clicking button-1 in the trough will cause its adjustment's page_increment to be added or subtracted from its value, and the slider to be moved accordingly. Clicking mouse button-2 in the trough will jump the slider to the point at which the button was clicked. Clicking any button on a scrollbar's arrows will cause its adjustment's value to change step_increment at a time.
It may take a little while to get used to, but by default, scrollbars as well as scale widgets can take the keyboard focus in GTK. If you think your users will find this too confusing, you can always disable this by unsetting the GTK2.CanFocus flag on the scrollbar, like this:
scrollbar->unset_flag(GTK2.CanFocus);
The key bindings (which are, of course, only active when the widget has focus) are slightly different between horizontal and vertical range widgets, for obvious reasons. They are also not quite the same for scale widgets as they are for scrollbars, for somewhat less obvious reasons (possibly to avoid confusion between the keys for horizontal and vertical scrollbars in scrolled windows, where both operate on the same area).
Properties: GTK2.Adjustment adjustment int inverted int update-policy
Style properties: int arrow-displacement-x int arrow-displacement-y int slider-width int stepper-size int stepper-spacing int trough-border
Signals: adjust_bounds
change_value
move_slider
value_changed
inherit GTK2.Widget : Widget
GTK2.Adjustment get_adjustment()
Gets the W(Adjustment) which is the "model" object for W(Range).
int get_inverted()
Gets the value set by set_inverted().
int get_update_policy()
Gets the update policy.
float get_value()
Gets the current value.
GTK2.Range set_adjustment(GTK2.Adjustment pos)
set_adjustment() does absolutely nothing if you pass it the adjustment that range is already using, regardless of whether you changed any of its fields or not. If you pass it a new Adjustment, it will unreference the old one if it exists (possibly destroying it), connect the appropriate signals to the new one, and call the private function gtk_range_adjustment_changed(), which will (or at least, is supposed to...) recalculate the size and/or position of the slider and redraw if necessary.
GTK2.Range set_increments(float step, float page)
Sets the step and page sizes. The step size is used when the user clicks the W(Scrollbar) arrows or moves W(Scale) via arrow keys. The page size is used for example when moving via Page Up or Page Down keys.
GTK2.Range set_inverted(int setting)
Ranges normally move from lower to higher values as the slider moves from top to bottom or left to right. Inverted ranges have higher values at the top or on the right rather than on the bottom or left.
GTK2.Range set_range(float min, float max)
Sets the allowable values, and clamps the range value to be between min and max.
GTK2.Range set_update_policy(int when)
The "update policy" of a range widget defines at what points during user interaction it will change the value field of its Adjustment and emit the "value_changed" signal on this Adjustment. The update policies are:
This is the default. The "value_changed" signal is emitted continuously, i.e., whenever the slider is moved by even the tiniest amount.
The "value_changed" signal is only emitted once the slider has stopped moving and the user has released the mouse button.
The "value_changed" signal is emitted when the user releases the mouse button, or if the slider stops moving for a short period of time.
GTK2.Range set_value(float value)
Sets the current value; if the value is outside the minimum or maximum range values, it will be clamped to fit inside them. The range emits the "value-changed" signal if the value changes.
| CLASS GTK2.Hbox |
Most packing is done by creating boxes. These are invisible widget containers that we can pack our widgets into which come in two forms, a horizontal box, and a vertical box. This is the horizontal one. When packing widgets into a horizontal box, the objects are inserted horizontally from left to right or right to left depending on the call used.
GTK2.Hbox(0,0)->add(GTK2.Button("Hello"))->add(GTK2.Button("World"))->pack_end_defaults(GTK2.Button("From right"))->pack_start_defaults(GTK2.Button("From left"))
![]()
GTK2.Hbox(1,0)->add(GTK2.Button("Hello"))->add(GTK2.Button("World"))->pack_end_defaults(GTK2.Button("From right"))->pack_start_defaults(GTK2.Button("From left"))
![]()
GTK2.Hbox(1,40)->add(GTK2.Button("Hello"))->add(GTK2.Button("World"))->pack_end_defaults(GTK2.Button("From right"))->pack_start_defaults(GTK2.Button("From left"))
![]()
inherit GTK2.Box : Box
GTK2.Hbox GTK2.Hbox(int|mapping uniformp_or_props, int hpadding)
Create a new horizontal box widget. If all_same_size is true, all widgets will have exactly the same size. hpadding is added to the left and right of the children.
| CLASS GTK2.Action |
Properties: GTK2.ActionGroup action-group int hide-if-empty int is-important string label string name int sensitive string short-label string stock-id string tooltip int visible int visible-horizontal int visible-overflown int visible-vertical
Signals: activate
inherit G.Object : Object
GTK2.Action activate()
Emits the "activate" signal, if it isn't insensitive.
GTK2.Action block_activate_from(GTK2.Widget proxy)
Disables calls to the activate() function by signals on the proxy. This is used to break notification loops for things like check or radio actions.
GTK2.Action connect_accelerator()
Installs the accelerator if this action widget has an accel path and group.
GTK2.Action connect_proxy(GTK2.Widget proxy)
Connects a widget to an action object as a proxy. Synchronises various properties of the action with the widget (such as label text, icon, tooltip, etc), and attaches a callback so that the action gets activated when the proxy widget does.
GTK2.Action GTK2.Action(string|mapping name_or_props, string|void label, string|void tooltip, string|void stock_id)
Creates a new object.
GTK2.Widget create_icon(int icon_size)
This function is intended for use by action implementations to create icons displayed in the proxy widgets. One of ICON_SIZE_BUTTON , ICON_SIZE_DIALOG , ICON_SIZE_DND , ICON_SIZE_INVALID , ICON_SIZE_LARGE_TOOLBAR , ICON_SIZE_MENU and ICON_SIZE_SMALL_TOOLBAR .
GTK2.Widget create_menu_item()
Creates a menu item widget that proxies for the action.
GTK2.Widget create_tool_item()
Creates a toolbar item widget that proxies for the action.
GTK2.Action disconnect_accelerator()
Undoes the effect of one call to connect_accelerator().
GTK2.Action disconnect_proxy(GTK2.Widget proxy)
Disconnects a proxy widget. Does not destroy the widget.
string get_accel_path()
Returns the accel path for this action.
string get_name()
Returns the name of the action.
array get_proxies()
Returns the proxy widgets.
int get_sensitive()
Returns whether the action itself is sensitive. Note that this doesn't necessarily mean effective sensitivity.
int get_visible()
Returns whether the action itself is visible.
int is_sensitive()
Returns whether the action is effectively sensitive.
int is_visible()
Returns whether the action is effectively visible.
GTK2.Action set_accel_group(GTK2.AccelGroup group)
Sets the GTK2.AccelGroup in which the accelerator for this action will be installed.
GTK2.Action set_accel_path(string accel_path)
Sets the accel path for this action. All proxy widgets associated with this action will have this accel path, so that their accelerators are consistent.
GTK2.Action set_sensitive(int setting)
Sets the sensitive property.
GTK2.Action set_visible(int setting)
Sets the visible property.
GTK2.Action unblock_activate_from(GTK2.Widget proxy)
Re-enables calls to the activate() function.
| CLASS GTK2.VbuttonBox |
A Vbutton_box is very similar to a Vbox. The major diffference is that the button box is made to pack buttons in, and has a few convenience function for normal button layouts.
GTK2.VbuttonBox()->add(GTK2.Button("Hello"))->add(GTK2.Button("World"))->set_size_request(100,300)

GTK2.VbuttonBox()->add(GTK2.Button("Hello"))->add(GTK2.Button("World"))->set_layout(GTK2.BUTTONBOX_SPREAD)->set_size_request(100,300)

GTK2.VbuttonBox()->add(GTK2.Button("Hello"))->add(GTK2.Button("World"))->set_layout(GTK2.BUTTONBOX_EDGE)->set_size_request(100,300)

GTK2.VbuttonBox()->add(GTK2.Button("Hello"))->add(GTK2.Button("World"))->set_layout(GTK2.BUTTONBOX_START)->set_size_request(100,300)

GTK2.VbuttonBox()->add(GTK2.Button("Hello"))->add(GTK2.Button("World"))->set_layout(GTK2.BUTTONBOX_END)->set_size_request(100,300)

inherit GTK2.ButtonBox : ButtonBox
GTK2.VbuttonBox GTK2.VbuttonBox(mapping|void props)
Create a new vertical button box
| CLASS GTK2.ToolItem |
Properties: int is-important int visible-horizontal int visible-vertical
Signals: create_menu_proxy
set_tooltip
toolbar_reconfigured
inherit GTK2.Bin : Bin
GTK2.ToolItem GTK2.ToolItem(mapping|void props)
Creates a new GTK2.ToolItem.
int get_expand()
Returns whether this item is allocated extra space.
int get_homogeneous()
Returns whether this item is the same size as the other homogeneous items.
int get_icon_size()
Returns the icon size used for this item. One of ICON_SIZE_BUTTON , ICON_SIZE_DIALOG , ICON_SIZE_DND , ICON_SIZE_INVALID , ICON_SIZE_LARGE_TOOLBAR , ICON_SIZE_MENU and ICON_SIZE_SMALL_TOOLBAR
int get_is_important()
Returns whether this item is considered important.
int get_orientation()
Returns the orientation used for this item. One of ORIENTATION_HORIZONTAL and ORIENTATION_VERTICAL
GTK2.Widget get_proxy_menu_item(string menu_item_id)
If menu_item_id matches the string passed to set_proxy_menu_item(), then return the corresponding GTK2.MenuItem.
int get_relief_style()
Returns the relief style of this item. One of RELIEF_HALF , RELIEF_NONE and RELIEF_NORMAL
int get_toolbar_style()
Returns the toolbar style use for this item. One of TOOLBAR_BOTH , TOOLBAR_BOTH_HORIZ , TOOLBAR_ICONS , TOOLBAR_SPACE_EMPTY , TOOLBAR_SPACE_LINE and TOOLBAR_TEXT
int get_use_drag_window()
Returns whether this item has a drag window.
int get_visible_horizontal()
Returns whether this item is visible on toolbars that are docked horizontally.
int get_visible_vertical()
Returns whether this item is visible when the toolbar is docked vertically.
GTK2.ToolItem rebuild_menu()
Calling this function signals to the toolbar that the overflow menu item for this item has changed. If the overflow menu is visible when this function is called, the menu will be rebuilt.
GTK2.Widget retrieve_proxy_menu_item()
Returns the GTK2.MenuItem that was last set by set_proxy_menu_item().
GTK2.ToolItem set_expand(int expand)
Sets whether this item is allocated extra space when there is more room on the toolbar than needed for the items. The effect is that the item gets bigger when the toolbar gets bigger and smaller when the toolbar gets smaller.
GTK2.ToolItem set_homogeneous(int homogeneous)
Sets whether this item is to be allocated the same size as other homogeneous items. The effect is that all homogeneous items will have the same width as the widest of the items.
GTK2.ToolItem set_is_important(int is_important)
Sets whether this item should be considered important.
GTK2.ToolItem set_proxy_menu_item(string menu_item_id, GTK2.Widget menu_item)
Sets the GTK2.MenuItem used in the toolbar overflow menu. The menu_item_id is used to identify the caller of this function and should also be used with get_proxy_menu_item().
GTK2.ToolItem set_tooltip(GTK2.Tooltips tooltips, string tip_text, string tip_private)
Sets the GTK2.Tooltips object to be used for this item, the text to be displayed as tool tip on the item and the private text to be used.
GTK2.ToolItem set_use_drag_window(int use_drag_window)
Sets whether this item has a drag window. When true the toolitem can be used as a drag source. When this item has a drag window it will intercept all events, even those that would otherwise be sent to a child.
GTK2.ToolItem set_visible_horizontal(int visible_horizontal)
Sets whether toolitem is visible when the toolbar is docked horizontally.
GTK2.ToolItem set_visible_vertical(int visible_vertical)
Sets whether this item is visible when the toolbar is docked vertically. Some tool items, such as text entries, are too wide to be useful on a vertically docked toolbar. If visible_vertical is false then this item will not appear on toolbars that are docked vertically.
| CLASS GTK2.GdkDragContext |
The drag context contains all information about the drag'n'drop connected to the signal to which it is an argument.
NOIMG
GDK2.DragContext drag_abort(int time)
Abort the drag
GDK2.DragContext drag_drop(int time)
Drag drop.
GDK2.DragContext drag_finish(int success, int del)
If success is true, the drag succeded. If del is true, the source should be deleted. time is the current time.
GDK2.DragContext drag_set_icon_default()
Use the default drag icon associated with the source widget.
GDK2.DragContext drag_set_icon_pixmap(GTK2.GdkPixmap p, GTK2.GdkBitmap b, int hot_x, int hot_y)
Set the drag pixmap, and optionally mask. The hot_x and hot_y coordinates will be the location of the mouse pointer, relative to the upper left corner of the pixmap.
GDK2.DragContext drag_set_icon_widget(GTK2.Widget widget, int hot_x, int hot_y)
Set the drag widget. This is a widget that will be shown, and then dragged around by the user during this drag.
GDK2.DragContext drag_status(int action)
Setting action to -1 means use the suggested action
GDK2.DragContext drop_reply(int ok)
Drop reply.
int get_action()
One of GDK_ACTION_ASK , GDK_ACTION_COPY , GDK_ACTION_DEFAULT , GDK_ACTION_LINK , GDK_ACTION_MOVE and GDK_ACTION_PRIVATE ;
int get_actions()
A bitwise or of one or more of GDK_ACTION_ASK , GDK_ACTION_COPY , GDK_ACTION_DEFAULT , GDK_ACTION_LINK , GDK_ACTION_MOVE and GDK_ACTION_PRIVATE ;
int get_is_source()
Is this application the source?
int get_protocol()
One of GDK_DRAG_PROTO_LOCAL , GDK_DRAG_PROTO_MOTIF , GDK_DRAG_PROTO_NONE , GDK_DRAG_PROTO_OLE2 , GDK_DRAG_PROTO_ROOTWIN , GDK_DRAG_PROTO_WIN32_DROPFILES and GDK_DRAG_PROTO_XDND
GTK2.Widget get_source_widget()
Return the drag source widget.
int get_start_time()
The start time of this drag, as a unix time_t (seconds since 0:00 1/1 1970)
int get_suggested_action()
One of GDK_ACTION_ASK , GDK_ACTION_COPY , GDK_ACTION_DEFAULT , GDK_ACTION_LINK , GDK_ACTION_MOVE and GDK_ACTION_PRIVATE ;
| CLASS GTK2.TearoffMenuItem |
A GTK2.TearoffMenuItem is a special W(MenuItem) which is used to tear off and reattach its menu.
When its menu is shown normally, the GTK2.TearoffMenuItem is drawn as a dotted line indicating that the menu can be torn off. Activating it causes its menu to be torn off and displayed in its own window as a tearoff menu.
When its menu is shown as a tearoff menu, the GTK2.TearoffMenuItem
is drawn as a dotted line which has a left pointing arrow graphic
indicating that the tearoff menu can be reattached. Activating it
will erase the tearoff menu window.
GTK2.TearoffMenuItem()->set_size_request(100,0)
![]()
inherit GTK2.MenuItem : MenuItem
GTK2.TearoffMenuItem GTK2.TearoffMenuItem(mapping|void props)
Create a new tearoff menu item
| CLASS GTK2.Pango.Layout |
Pango Layout.
Pango.Layout context_changed()
Forces recomputation of any state in the layout that might depend on the layout's context. This function should be called if you make changes to the context subsequent to creating the layout.
GTK2.Pango.Layout copy(GTK2.Pango.Layout src)
Does a copy of the src.
Pango.Layout GTK2.Pango.Layout(GTK2.Pango.Context context)
Create a new layout with attributes initialized to default values for a particular Pango.Context
int get_alignment()
Gets the alignment.
int get_auto_dir()
Gets whether to calculate the bidirectional base direction for the layout according to the contents of the layout.
GTK2.Pango.Context get_context()
Returns the Pango.Context.
array get_cursor_pos(int index)
Given an index within a layout, determines the positions of the strong and weak cursors if the insertion point is at that index. The position of each cursor is stored as a zero-width rectangle. The strong cursor is the location where characters of the directionality equal to the base direction of the layout are inserted. The weak cursor location is the location where characters of the directionality opposite to the base direction of the layout are inserted. Returns: array of mappings, each mapping is the same as index_to_pos().
int get_indent()
Gets the paragraph indent in pango units. A negative value indicates a hanging indent.
int get_justify()
Gets whether or not each complete line should be stretched to fill the entire width of the layout.
GTK2.Pango.LayoutLine get_line(int line)
Retrieves a specific line.
int get_line_count()
Retrieves the count of lines.
int get_single_paragraph_mode()
Gets the value set by set_single_paragraph_mode().
mapping get_size()
Determines the logical width and height in Pango units.
int get_spacing()
Gets the amount of spacing between the lines.
GTK2.Pango.TabArray get_tabs()
Gets the current W(TabArray) used by this layout. If no W(TabArray) has been set, then the default tabs are in use and 0 is returned. Default tabs are every 8 spaces.
string get_text()
Gets the text.
int get_width()
Gets the line wrap width.
int get_wrap()
Gets the wrap mode for the layout.
mapping index_to_pos(int index)
Converts from an index to the onscreen position corresponding to the grapheme at that index, which is represented as a rectangle. Note that x is always the leading edge of the grapheme and x+width the trailing edge of the grapheme. If the direction of the grapheme is right-to-left, then width will be negative.
Returns: ([ "x": x coordinate, "y": y coordinate, "width": width of the rectangle, "height": height of the rectangle ])
mapping move_cursor_visually(int strong, int old_index, int old_trailing, int dir)
Computes a new cursor position from an old position and a count of positions to move visually. If count is positive, then the new strong cursor position will be one position to the right of the old cursor position. If count is negative, then the new strong cursor position will be one position to the left of the old cursor position.
In the presence of bidirectional text, the correspondence between logical and visual order will depend on the direction of the current run, and there may be jumps when the cursor is moved off the end of a run.
Motion here is in cursor positions, not in characters, so a single call to move_cursor_visually() may move the cursor over multiple characters when multiple characters combine to form a single grapheme.
Pango.Layout set_alignment(int alignment)
Sets the alignment for the layout (how partial lines are positioned within the horizontal space available.) One of .
Pango.Layout set_auto_dir(int auto_dir)
Sets whether to calculate the bidirectional base direction for the layout according to the contents of the layout; when this flag is on (the default), then paragraphs that begin with strong right-to-left characters (Arabic and Hebrew principally), will have right-left-layout, paragraphs with letters from other scripts will have left-to-right layout. Paragraphs with only neutral characters get their direction from the surrounding paragraphs.
When false, the choice between left-to-right and right-to-left layout is done by according to the base direction of the Pango.Context.
Pango.Layout set_font_description(GTK2.Pango.FontDescription desc)
Sets the default font description for the layout. If no font description is set on the layout, the font descriptions from the layout's context is used.
Pango.Layout set_indent(int indent)
Sets the width in pango units to indent each paragraph. A negative value of indent will produce a hanging indent. That is, the first line will have the full width, and subsequent lines will be indented by the absolute value of indent.
Pango.Layout set_justify(int justify)
Sets whether or not each complete line should be stretched to fill the entire width of the layout. This stretching is typically done by adding whitespace, but for some scripts (such as Arabic), the justification is done by extending the characters.
Pango.Layout set_markup(string markup, int length)
Same as set_markup_with_accel(), but the markup text isn't scanned for accelerators.
Pango.Layout set_markup_with_accel(string markup, int length, int|void accel_marker)
Sets the layout text and attribute from marked-up text. Replaces the current text and attribute list.
If accel_marker is nonzero, the given character will mark the character following it as an accelerator. For example, the accel marker might be an ampersand or underscore. All characters marked as an acclerator will receive a GTK2.PANGO_UNDERLINE_LOW attribute, and the first character so marked will be returned. Two accel_marker characters following each other produce a single literal accel_marker character.
Pango.Layout set_single_paragraph_mode(int setting)
If setting is true, do not treat newlines and similar characters as paragraph separators; instead, keep all text in a single paragraph, and display a glyph for paragraph separator characters. Used when you want to allow editing of newlines on a single text line.
Pango.Layout set_spacing(int spacing)
Sets the amount of spacing between the lines.
Pango.Layout set_tabs(GTK2.Pango.TabArray tabs)
Sets the tabs to use, overriding the default tabs (by default, tabs are every 8 spaces). If tabs is omitted, the default tabs are reinstated.
Pango.Layout set_text(string text, int length)
Sets the text of the layout.
Pango.Layout set_width(int width)
Sets the width to which the lines should be wrapped.
Pango.Layout set_wrap(int wrap)
Sets the wrap mode; the wrap mode only has an effect if a width is set on the layout with set_width(). To turn off wrapping, set the width to -1. One of .
mapping xy_to_index(int x, int y)
Converts from x and y position within a layout to the byte index to the character at that logical position. If the y position is not inside the layout, the closest position is chosen (the position will be clamped inside the layout). If the X position is not within the layout, then the start or the end of the line is chosen as describe for x_to_index(). If either the x or y positions were not inside the layout, then returns 0.
Returns: ([ "index": byte index, "trailing": where in grapheme user clicked ]).
| CLASS GTK2.CellRendererPixbuf |
Properties: GDK2.Pixbuf pixbuf GDK2.Pixbuf pixbuf-expander-closed GDK2.Pixbuf pixbuf-expander-open string stock-detail string stock-id int stock-size
inherit GTK2.CellRenderer : CellRenderer
GTK2.CellRendererPixbuf GTK2.CellRendererPixbuf(mapping|void props)
Creates a new W(CellRendererPixbuf). Adjust rendering parameters using object properties. Object properties can be set globally with G.Object->set(). Also, with W(TreeViewColumn), you can bind a property to a value in a W(TreeModel). For example, you can bind the "pixbuf" property on the cell renderer to a pixbuf value in the model, thus rendering a different image in each row of the W(TreeView).
| CLASS GTK2.FontButton |
Properties: string font-name int show-size int show-style string title int use-font int use-size
Signals: font_set
inherit GTK2.Button : Button
GTK2.FontButton GTK2.FontButton(string|mapping font_or_props)
Create a new font picker widget. If font is specified, it will be displayed in the font selection dialog.
string get_font_name()
Retrieves the name of the currently selected font.
int get_show_size()
Returns whether the font size will be shown in the label.
int get_show_style()
Returns whether the name of the font style will be shown in the label.
string get_title()
Retrieves the title of the font selection dialog.
int get_use_font()
Returns whether the selected font is used in the label.
int get_use_size()
Returns whether the selected size is used in the label.
int set_font_name(string font)
Sets or updates the currently-displayed font.
GTK2.FontButton set_show_size(int setting)
If setting is true, the font size will be displayed along with the name of the selected of the selected font.
GTK2.FontButton set_show_style(int setting)
If setting is true, the font style will be displayed along with the name of the selected font.
GTK2.FontButton set_title(string title)
Sets the title for the font selection dialog.
GTK2.FontButton set_use_font(int setting)
If setting is true, the font name will be written using the selected font.
GTK2.FontButton set_use_size(int setting)
If setting is true, the font name will be written using the selected size.
| CLASS GTK2.RadioToolButton |
Properties: GTK2.RadioToolButton group
inherit GTK2.ToggleToolButton : ToggleToolButton
GTK2.RadioToolButton GTK2.RadioToolButton(GTK2.RadioToolButton groupmember)
Create a GTK2.RadioToolButton. Use without a parameter for a new group. Use with another GTK2.RadioToolButton to add another button to the same group as a previous button.
array get_group()
Get the group this button belongs to.
| CLASS GTK2.Gnome2IconEntry |
This widget provides the facilities to select an icon. An icon is displayed inside a button, when the button is pressed, an Icon selector (a dialog with a W(GnomeIconSelection) widget) pops up to let the user choose an icon. It also allows one to Drag and Drop the images to and from the preview button. Properties: string browse-dialog-title string filename string history-id GTK2.Dialog pick-dialog string pixmap-subdir
Signals: browse
changed
inherit GTK2.Vbox : Vbox
Gnome2.IconEntry GTK2.Gnome2IconEntry(string history_id, string title)
Creates a new icon entry widget
string get_filename()
Gets the file name of the image if it was possible to load it into the preview. That is, it will only return a filename if the image exists and it was possible to load it as an image.
GTK2.Widget pick_dialog()
If a pick dialog exists, returns it. This is if you need to do something with all dialogs. You would use the browse signal with connect_after to get the pick dialog when it is displayed.
Gnome2.IconEntry set_browse_dialog_title(string title)
Set the title of the browse dialog.
int set_filename(string filename)
Sets the icon of Gnome2.IconEntry to be the one pointed to by filename.
Gnome2.IconEntry set_history_id(string history_id)
Set the history_id of the entry in the browse dialog and reload the history.
Gnome2.IconEntry set_pixmap_subdir(string subdir)
Sets the subdirectory below gnome's default pixmap directory to use as the default path for the file entry.
| CLASS GTK2.TextIter |
A TextIter.
int backward_char()
Moves backward by one character offset. Returns true if the movement was possible; if it was the first in the buffer (character offset 0), backward_char() returns false for convenience when writing loops.
int backward_chars(int count)
Moves count characters backward, if possible (if count would mmove past the start or end of the buffer, moves to the start or end of the buffer). The return value indicates whether the iterator moved onto a dereferenceable position; if it didn't move, or moved onto the end iterator, then false is returned. If count is 0, the function does nothing and returns false.
int backward_cursor_position()
Like forward_cursor_position(), but moves backward.
int backward_cursor_positions(int count)
Moves up to count cursor positions.
int backward_line()
Moves to the start of the previous line. Returns true if this iter could be moved; i.e. if iter was at character offset 0, this function returns false. Therefore if it was already on line 0, but not at the start of the line, it is snapped to the start of the line and the function returns true. (Note that this implies that in a loop calling this function, the line number may not change on every iteration, if your first iteration is on line 0.)
int backward_lines(int count)
Moves count lines backward.
array backward_search(string str, int flags, GTK2.TextIter limit)
Same as forward_search(), but searches backward.
int backward_sentence_start()
Moves backward to the previous sentence start.
int backward_sentence_starts(int count)
Call backward_sentence_start() count times.
int backward_to_tag_toggle(GTK2.TextTag tag)
Moves backward to the next toggle. See forward_to_tag_toggle().
int backward_visible_cursor_position()
Moves backward to the previous visible cursor position.
int backward_visible_cursor_positions(int count)
Moves up to count visible cursor positions.
int backward_visible_line()
Moves to the start of the previous visible line. Returns TRUE if iter could be moved; i.e. if iter was at character offset 0, this function returns FALSE. Therefore if iter was alreayd on line 0, but not at the start of the line, iter is snapped to the start of the line and the function returns TRUE. (Note that this implies that in a loop calling this function, the line number may not change on every iteration, if your first iteration is on line 0).
int backward_visible_lines(int count)
Moves count visible lines backward, if possible (if count would move past the start or end of the buffer, moves to the start or end of the buffer). The return value indicates whether the iterator moved onto a dereferenceable position; if the iterator didn't move, or moved onto the end iterator, then FALSE is returned. If count is 0, the function does nothing and returns FALSE. If count is negative, moves forward by 0 - count lines.
int backward_visible_word_start()
Moves backward to the previous visible word start.
int backward_visible_word_starts(int count)
Call backward_visible_word_start() count times
int backward_word_start()
Moves backward to the previous word start.
int backward_word_starts(int count)
Calls backward_word_start() up to count times.
int begins_tag(GTK2.TextTag tag)
Returns true if tag is toggled on at exactly this point. If tag is omitted, returns true if any tag is toggled on at this point. Note that begins_tag() returns true if this iter is the start of the tagged range; has_tag() tells you whether an iterator is within a tagged range.
int can_insert(int default_editability)
Considering the default editability of the buffer, and tags that affect editability, determines whether text inserted here would be editabled. If text inserted here would be editabled then the user should be allowed to insert text here. insert_interactive() uses this function to decide whether insertions are allowed at a given position.
int compare(GTK2.TextIter rhs)
Returns -1 if this iterator is less than rhs, 1 if greater than, and 0 if they're equal. Ordering is in character offset order, i.e. the first character in the buffer is less than the second character in the buffer.
int editable(int default_setting)
Returns whether the character at this location is within an editable region of text. Non-editable text is "locked" and can't be changed by the user via W(TextView). This function is simply a convenience wrapper around get_attributes(). If no tags applied to this text editability, default_setting will be returned.
You don't want to use this function to decide whether text can be inserted here, because for insertion you don't want to know whether the char at iter is inside an editable range, you want to know whether a new characer inserted here would be inside an editable range. Use can_insert() to handle this case.
int ends_line()
Returns true if iter points to the start of the paragraph delimiter characters for a line (delimiters will be either a newline, a carriage return, a carriage return followed by a newline, or a Unicode paragraph separator character). Note that an iterator pointing to the \n of a \r\n pair will not be counted as the end of a line, the line ends before the \r. The end iterator is considered to be at the end of a line, even though there are no paragraph delimiter chars there.
int ends_sentence()
Determines whether this iter ends a sentence.
int ends_tag(GTK2.TextTag tag)
Returns true if tag is toggled off at exactly this point. If tag is omitted, returns true if any tag is toggled off at this point. Not that ends_tag() returns true if this iter it at the end of the tagged range; has_tag() tells you whether an iterator is within a tagged range.
int ends_word()
Determines whether this iter ends a natural-language word. Word breaks are determined by Pango and should be correct for nearly any language (if not, the correct fix would be to the Pango word break algorithms).
int equal(GTK2.TextIter rhs)
Tests whether two iterators are equal, using the fastest possible mechanism. This function is very fast; you can expect it to perform better than e.g. getting the character offset for each iterator and comparing offsets yourself. Also, it's a bit faster than compare().
int forward_char()
Moves this iterator forward by one character offset. Note that images embedded in the buffer occopy 1 character slot, to forward_char() may actually move onto an image instead of a character, if you have images in your buffer. If this iterator is the end iterator or one character before it, it will now point at the end iterator, and forward_char() returns false for convenience when writing loops.
int forward_chars(int count)
Moves count characters if possible (if count would move past the start or end of the buffer, moves to the start or end of the buffer). The return value indicates whether the new position is different from its original position, and dereferenceable (the last iterator in the buffer is not). If count is 0, the function does nothing and returns false.
int forward_cursor_position()
Moves this iterator forward by a single cursor position. Cursor positions are (unsurprisingly) positions where the cursor can appear. Perhaps surprisingly, there may not be a cursor position between all characters. The most common example for European languages would be a carriage return/newline sequence. For some Unicode characters, the equivalent of say the letter "a" with an accent mark will be represented as two characters, first the letter then a "combining mark" that causes the accent to be rendered; so the cursor can't go between those two characters. See also Pango.LogAttr and pango_break().
int forward_cursor_positions(int count)
Moves up to count cursor positions.
int forward_line()
Moves to the start of the next line. Returns true if there was a next line to move to, and false if this iter was simply moved to the end of the buffer and is now not dereferenceable, or if it was already at the end of the buffer.
int forward_lines(int count)
Moves count lines forward, if possible (if count would move past the start or end of the buffer, moves to the start or end of the buffer). The return value indicates whether the iterator moved onto a dereferenceable position; if the iterator didn't move, or moved onto the end iterator, then false is returned. If count is 0, the function does nothing and returns false. If count is negative, moves backward by 0 - count lines.
array forward_search(string str, int flags, GTK2.TextIter limit)
Searches forward for str. Returns two GTK2.TextIter objects, one pointing to the first character of the match, and the second pointing to the first character after the match. The search will not continue past limit. Note that a search is a linear or O(n) operation, so you may wish to use limit to avoid locking up your UI on large buffers.
If the GTK2.TEXT_SEARCH_VISIBLE_ONLY flag is present, the match may have invisible text interspersed in str, i.e. str will be a possibly non-contiguous subsequence of the matched range. Similarly, if you specify GTK2.TEXT_SEARCH_TEXT_ONLY, the match may have pixbufs or child widgets mixed inside the matched range. If these flags are not given, the match must be exact; the special 0xFFFC character in str will match embedded pixbufs or child widgets.
int forward_sentence_end()
Moves forward to the next sentence end.
int forward_sentence_ends(int count)
Call forward_sentence_ends() count times.
GTK2.TextIter forward_to_end()
Moves forward to the "end iterator", which points one past the last valid character in the buffer. get_char() called on the end iterator returns 0, which is convenient for writing loops.
int forward_to_line_end()
Moves the iterator to point to the paragraph delimiter characters, which will be either a newline, a carriage return, a carriage return/newline sequence, or the Unicode paragraph separator character. If the iterator is already at the paragraph delimiter characters, moves to the paragraph delimiter characters for the next line. If iter is on the last line in the buffer, which does not end in paragraph delimiters, moves to the end iterator (end of the last line), and returns false.
int forward_to_tag_toggle(GTK2.TextTag tag)
Moves forward to the next toggle (on or off) of tag, or to the next toggle of any tag if tag is omitted. If no matching tag toggles are found, returns false, otherwise true. Does not return toggles located at this iter, only toggles after. Sets this iter to the location of the toggle, or to the end of the buffer if no toggle is found.
int forward_visible_cursor_position()
Moves forward to the next visible cursor position.
int forward_visible_cursor_positions(int count)
Moves up to count visible cursor positions.
int forward_visible_line()
Moves to the start of the next visible line. Returns TRUE if there was a next line to move to, and FALSE if iter was simply moved to the end of the buffer and is now not dereferenceable, or if iter was already at the end of the buffer.
int forward_visible_lines(int count)
Moves count visible lines forward, if possible (if count would move past the start or end of the buffer, moves to the start or end of the buffer). The return value indicates whether the iterator moved onto a dereferenceable position; if the iterator didn't move, or moved onto the end iterator, then FALSE is returned. If count is 0, the function does nothing and returns FALSE. If count is negative, moves backward by 0 - count lines.
int forward_visible_word_end()
Moves forward to the next visible word end.
int forward_visible_word_ends(int count)
Call forward_visible_word_end() count times.
int forward_word_end()
Moves forward to the next word end.
int forward_word_ends(int count)
Calls forward_word_end() up to count times.
GTK2.TextIter free()
Free an iterator.
GTK2.TextBuffer get_buffer()
Returns the W(TextBuffer) this iterator is associated with.
int get_bytes_in_line()
Returns the number of bytes in the line, including the paragraph delimiters.
int get_char()
Returns the Unicode character at this iterator. If the element at this iterator is a non-character element, such as an image embedded in the buffer, the Unicode "unknown" character 0xFFFc is returned.
int get_chars_in_line()
Returns the number of characters in the line, including the paragraph delimiters.
GTK2.TextChildAnchor get_child_anchor()
If this location contains a child anchor, the anchor is returned.
int get_line()
Returns the line number containing this iterator.
int get_line_index()
Returns the byte index of the iterator, counting from the start of a newline-terminated line. Rember that W(TextBuffer) encodes text in UTF-8, and that characters can require a variable number of bytes to represent.
int get_line_offset()
Returns the character offset of the iterator, counting from the start of a newline-terminated line.
array get_marks()
Returns a list of W(TextMark) at this location. Because marks are not iterable (they don't take up any "space" in the buffer, they are just marks in between iterable locations), multiple marks can exist in the same place. The returned list is not in any meaningful order.
int get_offset()
Returns the character offset of an iterator.
GTK2.GdkPixbuf get_pixbuf()
If the element at iter is a pixbuf, it is returned.
string get_slice(GTK2.TextIter end)
Returns the text in the given range. A "slice" is an array of characters encoded in UTF-8 foramt, including the Unicode "unknown" character 0xFFFC for iterable non-character elements in the buffer, such as images. Because images are encoded in the slice, byte and character offsets in the returned array will correspond to bytes offsets in the text buffer. Note that 0xFFFC can occur in normal text as well, so it is not a reliable indicator that a pixbuf or widget is in the buffer.
array get_tags()
Returns a list of tags that apply to iter, in ascending order of priority (highest-priority tags are last).
string get_text(GTK2.TextIter end)
Returns text in the given range. If the range contains non-text elements such as images, the character and byte offsets in the returned string will not correspond to character and bytes offsets in the buffer.
array get_toggled_tags(int toggled_on)
Returns a list of W(TextTag) that are toggled on or off at this point. (If toggled_on is true, the list contains tags that are toggled on). If a tag is toggled on at this iterator, then some non-empty range of characters following this iter has that tag applied to it. If a tag is toggled off, then some non-empty range following this iter does not have the tag applied to it.
int get_visible_line_index()
Returns the number of bytes from the start of the line to this iter, not counting bytes that are invisible due to tags with the invisible flag toggled on.
int get_visible_line_offset()
Returns the offset in characters from the start of the line, not not counting characters that are invisible due to tags with the invisible tag toggled on.
string get_visible_slice(GTK2.TextIter end)
Like get_slice(), but invisible text is not included.
string get_visible_text(GTK2.TextIter end)
Like get_text(), but invisible text is not include.
int has_tag(GTK2.TextTag tag)
Returns true if this iterator is within a range tagged with tag.
int in_range(GTK2.TextIter start, GTK2.TextIter end)
Checks whether this iterator falls in the range [start,end). start and end must be in ascending order.
int inside_sentence()
Determines whether this is inside a sentence (as opposed to int between two sentences, e.g. after a period and before the first letter of the next sentence). Sentence boundaries are determined by Pango and should be correct for nearly language (if not, the correct fix would be to the Pango text boundary algorithms).
int inside_word()
Determines whether this iter is inside a natural-language word ass opposed to say inside some whitespace).
int is_cursor_position()
See forward_cursor_position() or Pango.LangAttr or pango_break() for details on what a cursor position is.
int is_end()
Returns true if this location is the end iterator, i.e. one past the last dereferenceable iterator in the buffer. is_end() is the most efficient way to check whether an iterator is the end iterator.
int is_start()
Returns true if this is the first iterator in the buffer, that is if it has a character offset of 0.
GTK2.TextIter order(GTK2.TextIter second)
Swaps this iter for second if second comes first in the buffer. That is, ensures that this iterator and second are in sequence. Most text buffer functions that take a range call this automatically on your behalf, so there's no real reason to call it yourself in those cases. There are some exceptions, such as in_range(), that expect a pre-sorted range.
GTK2.TextIter set_line(int line_number)
Moves the iterator to the start of the line line_number. If line_number is negative or larger than the number of lines in the buffer, moves to the start of the last line in the buffer.
GTK2.TextIter set_line_index(int index)
Same as set_line_offset(), but works with a byte index. The given byte index must be at the start of a character, it can't be in the middle of a UTF-8 encoded character.
GTK2.TextIter set_line_offset(int offset)
Moves iterator within a line, to a new character (not byte) offset. The given character offset must be less than or equal to the number of characters in the line; if equal, iterator moves to the start of the next line. See set_line_index() if you have a byte index rather than a character offset.
GTK2.TextIter set_offset(int char_offset)
Sets to point to char_offset. char_offset counts from the start of the entire text buffer, starting with 0.
GTK2.TextIter set_visible_line_index(int index)
Same as set_line_index(), but works with visible byte index. The given byte index must be at the start of a character, it can't be in the middle of a UTF-8 encoded character.
GTK2.TextIter set_visible_line_offset(int offset)
Like set_line_offset(), but the offset is in visible characters, i.e. text with a tag making it invisible is not counted in the offset.
int starts_line()
Returns true if this iter begins a paragraph, i.e. if get_line_offset() would return 0. However this function is potentially more efficient than get_line_offset() because it doesn't have to computer the offset, it just has to see whether it's 0.
int starts_sentence()
Determines whether this iter begins a sentence.
int starts_word()
Determines whether this iter begins a natural-language word. Word breaks are determined by Pango and should be correct for nearly any language (if not, the correct fix would be to the Pango word break algorithms).
int toggles_tag(GTK2.TextTag tag)
This is equivalent to begins_tag()||ends_tag(), i.e it tells you whether a range with tag applied to it beings or ends here.
| CLASS GTK2.MenuItem |
Menu items, to be added to menus. Style properties: int arrow-spacing int horizontal-padding int selected-shadow-type int toggle-spacing
Signals: activate
activate_item
toggle_size_allocate
toggle_size_request
inherit GTK2.Item : Item
GTK2.MenuItem activate()
Emulate an activate signal
GTK2.MenuItem GTK2.MenuItem(string|mapping label_or_props)
If a string is supplied, a W(Label) widget is created using that string and added to the item. Otherwise, you should add another widget to the list item with ->add().
GTK2.MenuItem deselect()
Emulate a deselect signal
int get_right_justified()
Gets whether the menu item appears justified at the right side of the menu bar.
GTK2.Widget get_submenu()
Gets the submenu underneath this menu item.
GTK2.MenuItem remove_submenu()
Remove the submenu for this menu button.
GTK2.MenuItem select()
Emulate a select signal
GTK2.MenuItem set_accel_path(string path)
Sets the accelerator path.
GTK2.MenuItem set_right_justified(int setting)
Make the menu item stick to the right edge of it's container.
GTK2.MenuItem set_submenu(GTK2.Widget menu)
Set the submenu for this menu button.
GTK2.MenuItem toggle_size_allocate(int allocation)
Emits the "toggle-size-allocate" signal on the given item.
int toggle_size_request(int requisition)
Emits the "toggle-size-request" signal on the given item.
| CLASS GTK2.AspectFrame |
A W(Frame) widget that always maintain a specified ratio between width and height. width/height == ratio
GTK2.AspectFrame("Title",0.5,0.5,0.4,0)->add( GTK2.Label("Wrong aspect"))->set_size_request(200,200)

Properties: int obey-child float ratio float xalign float yalign
inherit GTK2.Frame : Frame
GTK2.AspectFrame GTK2.AspectFrame(mapping|string label, float|void xalign, float|void yalign, float|void ratio, int|void obey_child)
Create a new frame. Arguments are label, xalign, yalign, ratio, obey_child xalign is floats between 0 and 1, 0.0 is upper (or leftmost), 1.0 is lower (or rightmost). If 'obey_child' is true, the frame will use the aspect ratio of it's (one and only) child widget instead of 'ratio'.
GTK2.AspectFrame set(float xalign, float yalign, float ratio, int obey_child)
Set the aspec values. Arguments are xalign, yalign, ratio, obey_child xalign is floats between 0 and 1, 0.0 is upper (or leftmost), 1.0 is lower (or rightmost). If 'obey_child' is true, the frame will use the aspect ratio of it's (one and only) child widget instead of 'ratio'.
| CLASS GTK2.Scale |
The GTK2.Scale widget is an abstract class, used only for deriving the subclasses GTK2.Hscale and GTK2.Vscale.
See W(Range) for generic range documentation
Properties: int digits int draw-value int value-pos
Style properties: int slider-length int value-spacing
Signals: format_value
inherit GTK2.Range : Range
int get_digits()
Gets the number of decimal places that are displayed.
int get_draw_value()
Returns whether the current value is displayed as a string next to the slider.
GTK2.Pango.Layout get_layout()
Gets the Pango.Layout used to display the scale.
mapping get_layout_offsets()
Obtains the coordinates where the scale will draw the Pango.Layout representing the text in the scale. Remember when using the Pango.Layout function you need to convert to and from pixels using PANGO_SCALE.
int get_value_pos()
Gets the position in which the current value is displayed.
GTK2.Scale set_digits(int precision)
Sets the number of decimal places that are displayed in the value.
GTK2.Scale set_draw_value(int drawp)
Specifies whether the current value is displayed as a string next to the slider.
GTK2.Scale set_value_pos(int where)
Sets the position in which the current value is displayed. One of POS_BOTTOM , POS_LEFT , POS_RIGHT and POS_TOP
| CLASS GTK2.Editable |
Interface for text-editing widgets.
Signals: changed
delete_text
insert_text
GTK2.Editable copy_clipboard()
Causes the characters in the current selection to be copied to the clipboard.
GTK2.Editable cut_clipboard()
Causes the characters in the current selection to be copied to the clipboard and then deleted.
GTK2.Editable delete_selection()
Deletes the current contents of the selection.
GTK2.Editable delete_text(int start, int end)
Deletes a sequence of characters.
string get_chars(int start, int end)
Retrieves a sequence of characters.
int get_editable()
Retrieves whether this widget is editable.
int get_position()
Retrieves the current cursor position.
array get_selection_bounds()
Returns the selection bounds.
int insert_text(string text, int length, int pos)
Inserts text at a given position. Returns the position after the new text.
GTK2.Editable paste_clipboard()
Causes the contents of the clipboard to be pasted into the given widget at the current cursor position.
GTK2.Editable select_region(int start, int end)
Selects a region of text.
GTK2.Editable set_editable(int setting)
Determines if the user can edit the text or not.
GTK2.Editable set_position(int pos)
Sets the cursor position.
| CLASS GTK2.FileChooserDialog |
GtkFileChooserDialog should be used to retrieve file or directory names from the user. It will create a new dialog window containing a directory list, and a file list corresponding to the current working directory. The filesystem can be navigated using the directory list, the drop-down history menu, or the TAB key can be used to navigate using filename completion common in text based editors such as emacs and jed.
The default filename can be set using set_filename() and the selected filename retrieved using get_filename().
Use complete() to display files that match a given pattern. This can be used for example, to show only *.txt files, or only files beginning with gtk*.
Simple file operations; create directory, delete file, and rename file, are available from buttons at the top of the dialog. These can be hidden using hide_fileop_buttons() and shown again using show_fileop_buttons().
GTK2.FileChooserDialog("File selector", 0, GTK2.FILE_CHOOSER_ACTION_OPEN, ({(["text":"Transmogrify", "id":17]), (["text":"Never mind", "id":42])}))

inherit GTK2.Dialog : Dialog
inherit GTK2.FileChooser : FileChooser
GTK2.FileChooserDialog GTK2.FileChooserDialog(string title, GTK2.Window parent, int mode, array buttons)
Creates a new file selection dialog box. By default it will list the files in the current working directory. Operation buttons allowing the user to create a directory, delete files, and rename files will also be present by default.
| CLASS GTK2.GdkBitmap |
A bitmap is a black and white pixmap. Most commonly used as masks for images, widgets and pixmaps.
NOIMG
inherit GDK2.Drawable : Drawable
GDK2.Bitmap GTK2.GdkBitmap(int|Image.Image xsize_or_image, int|void ysize, string|void bitmap)
Create a new GDK2.Bitmap object. Argument is either an Image.image object, or {xsisze,ysize,xbitmapdata}.
GDK2.Bitmap destroy()
Destructor. Destroys the bitmap. This will free the bitmap on the X-server.
GDK2.Bitmap ref()
Add a reference
GDK2.Bitmap unref()
Remove a reference
| CLASS GTK2.SelectionData |
Placeholder class for GtkSelectionData.
| CLASS GTK2.TreeViewColumn |
Properties: float alignment int clickable int expand int fixed-width int max-width int min-width int reorderable int resizable int sizing TREE_VIEW_COLUMN_AUTOSIZE , TREE_VIEW_COLUMN_FIXED and TREE_VIEW_COLUMN_GROW_ONLY int sort-indicator int sort-order SORT_ASCENDING and SORT_DESCENDING int spacing string title int visible GTK2.Widget widget int width
Signals: clicked
inherit GTK2.Data : Data
inherit GTK2.CellLayout : CellLayout
GTK2.TreeViewColumn add_attribute(GTK2.CellRenderer cell_renderer, string attribute, int column)
Adds an attribute mapping to the list. The column is the column of the model to get a value from, and the attribute is the parameter on cell_rendere to be set from the value. So for example if column 2 of the model contains strings, you could have the "text" attribute of a W(CellRendererText) get its values from column 2.
mapping cell_get_position(GTK2.CellRenderer cell_renderer)
Obtains the horizontal position and size of a cell in a column. If the cell is not found in the column, returns -1 for start_pos and width.
mapping cell_get_size(GTK2.GdkRectangle cell_area)
Obtains the width and height needed to render the column.
int cell_is_visible()
Returns true if any of the cells packed into the colum are visible. For this to be meaningful, you must first initialize the cells with cell_set_cell_data().
GTK2.TreeViewColumn cell_set_cell_data(GTK2.TreeModel model, GTK2.TreeIter iter, int is_expander, int is_expanded)
Sets the cell renderer based on the model and iter. That is, for every attribute mapping in this column, it will get a value from the set column on the iter, and use that value to set the attribute on the cell renderer. This is used primarily by the W(TreeView).
GTK2.TreeViewColumn clear()
Unsets all the mappings on all renderers.
GTK2.TreeViewColumn clear_attributes(GTK2.CellRenderer cell_renderer)
Clears all existing attributes previously set.
GTK2.TreeViewColumn clicked()
Emits the "clicked" signal on the column. This function will only work if this column is clickable.
GTK2.TreeViewColumn GTK2.TreeViewColumn(string|mapping title_or_props, GTK2.CellRenderer renderer, string|void property, int|void col)
Creates a new W(TreeViewColumn).
GTK2.TreeViewColumn focus_cell(GTK2.CellRenderer cell)
Sets the current keyboard focus to be at cell, if the column contains 2 or more editable and activatable cells.
float get_alignment()
Returns the current x alignment. This value can range between 0.0 and 1.0.
array get_cell_renderers()
Returns an array of all the cell renderers in the column, in no partciular order.
int get_clickable()
Returns true if the user can click on the header for the column.
int get_expand()
Return true if the column expands to take any available space.
int get_fixed_width()
Gets the fixed width of the column.
int get_max_width()
Returns the maximum width in pixels, or -1 if no maximum width is set.
int get_min_width()
Returns the minimum width in pixels, or -1 if no minimum width is set.
int get_reorderable()
Returns true if the column can be reordered by the user.
int get_resizable()
Returns true if the column can be resized by the end user.
int get_sizing()
Returns the current type.
int get_sort_column_id()
Gets the logical column_id that the model sorts on when this column is selected for sorting.
int get_sort_indicator()
Gets the value set by set_sort_indicator();
int get_sort_order()
Gets the value set by set_sort_order().
int get_spacing()
Returns the spacing.
string get_title()
Returns the title of the widget.
int get_visible()
Returns true if the column is visible.
GTK2.Widget get_widget()
Returns the W(Widget) in the button on the column header. If a custom widget has not been set then 0 is returned.
int get_width()
Returns the current size in pixels.
GTK2.TreeViewColumn pack_end(GTK2.CellRenderer cell, int expand)
Packs the cell to the end of the column.
GTK2.TreeViewColumn pack_start(GTK2.CellRenderer cell, int expand)
Packs the cell into the beginning of the column. If expand is false, then the cell is allocated no more space than it needs. Any unused space is divied evenly between cels for which expand is true.
GTK2.TreeViewColumn queue_resize()
Flags the column, and the cell renderers added to this column, to have their sizes renegotiated.
GTK2.TreeViewColumn set_alignment(float xalign)
Sets the alignment of the title or custom widget inside the column header. The alignment determines its location inside the button - 0.0 for left, 0.5 for center, 1.0 for right.
GTK2.TreeViewColumn set_clickable(int clickable)
Sets the header to be active if clickable is true. When the header is active, then it can take keyboard focus, and can be clicked.
GTK2.TreeViewColumn set_expand(int expand)
Sets the column to take available extra space. This space is shared equally amongst all columns that have the expand set to true. If no column has this option set, then the last column gets all extra space. By default, every column is created with this false.
GTK2.TreeViewColumn set_fixed_width(int fixed_width)
Sets the size of the column in pixels. The is meaningful only if the sizing type is GTK2.TREE_VIEW_COLUMN_FIXED. The size of the column is clamped to the min/max width for the column. Please note that the min/max width of the column doesn't actually affect the "fixed-width" property of the widget, just the actual size when displayed.
GTK2.TreeViewColumn set_max_width(int max_width)
Sets the maximum width. If max_width is -1, then the maximum width is unset. Note, the column can actually be wider than max width if it's the last column in a view. In this case, the column expands to fill any extra space.
GTK2.TreeViewColumn set_min_width(int min_width)
Sets the minimum width. If min_width is -1, then the minimum width is unset.
GTK2.TreeViewColumn set_reorderable(int reorderable)
If reorderable is true, then the column can be reorderd by the end user dragging the header.
GTK2.TreeViewColumn set_resizable(int resizable)
If resizable is true, then the user can explicitly resize the column by grabbing the outer edge of the column button. If resizable is ture and the sizing mode of the column is GTK2.TREE_VIEW_COLUMN_AUTOSIZE, then the sizing mode is changed to GTK2.TREE_VIEW_COLUMN_GROW_ONLY.
GTK2.TreeViewColumn set_sizing(int type)
Sets the growth behavior of this columnt to type. One of TREE_VIEW_COLUMN_AUTOSIZE , TREE_VIEW_COLUMN_FIXED and TREE_VIEW_COLUMN_GROW_ONLY .
GTK2.TreeViewColumn set_sort_column_id(int column_id)
Sets the logical column_id that this column sorts on when this column is selected for sorting. Doing so makes the column header clickable.
GTK2.TreeViewColumn set_sort_indicator(int setting)
Call this function with a setting of true to display an arrow in the header button indicating the column is sorted. Call set_sort_order() to change the direction of the arrow.
GTK2.TreeViewColumn set_sort_order(int order)
Changes the appearance of the sort indicator.
This does not actually sort the model. Use set_sort_column_id() if you wnat automatic sorting support. This function is primarily for custom sorting behavior, and should be used in conjunction with GTK2.TreeSortable->set_sort_column() to do that. For custom models, the mechanism will vary.
The sort indicator changes direction to indicate normal sort or reverse sort. Note that you must have the sort indicator enabled to see anything when calling this function. One of SORT_ASCENDING and SORT_DESCENDING .
GTK2.TreeViewColumn set_spacing(int spacing)
Sets the spacing field, which is the number of pixels to place between cell renderers packed into it.
GTK2.TreeViewColumn set_title(string title)
Sets the title. If a custom widget has been set, then this value is ignored.
GTK2.TreeViewColumn set_visible(int visible)
Sets the visibility.
GTK2.TreeViewColumn set_widget(GTK2.Widget widget)
Sets the widget in the header to be widget. If widget is omitted, then the header button is set with a W(Label) set to the title.
| CLASS GTK2.SourceLanguage |
inherit G.Object : Object
int get_escape_char()
Gets the value of the ESC character in the given language.
array get_mime_types()
Returns a list of mime types for this language.
string get_name()
Returns the localized name of the language.
string get_section()
Returns the localized section of the language. Each language belongs to a section (ex. HTML belongs to the Markup section).
GTK2.SourceStyleScheme get_style_scheme()
Gets the style scheme associated with this language.
mapping get_tag_default_style(string id)
Gets the default style of the tag id.
mapping get_tag_style(string id)
Gets the style of the tag id. If the style is not defined, then returns the default style.
array get_tags()
Returns a list of tags for this language.
GTK2.SourceLanguage set_mime_types(array|void types)
Sets a list of mime types for this language. If omitted, this function will use the default mime types from the language file.
GTK2.SourceLanguage set_tag_style(string id, mapping|void style)
Sets the style of the tag id. If style is omitted, this function will restore the default style.
| CLASS GTK2.SpinButton |
The Spin Button widget is generally used to allow the user to select a value from a range of numeric values. It consists of a text entry box with up and down arrow buttons attached to the side. Selecting one of the buttons causes the value to "spin" up and down the range of possible values. The entry box may also be edited directly to enter a specific value.
The Spin Button allows the value to have zero or a number of decimal places and to be incremented/decremented in configurable steps. The action of holding down one of the buttons optionally results in an acceleration of change in the value according to how long it is depressed.
The Spin Button uses an W(Adjustment) object to hold information about the range of values that the spin button can take.
The attributes of an W(Adjustment) are used by the Spin Button in the following way: <ul><li>value: initial value for the Spin Button</li> <li>lower: lower range value</li> <li>upper: upper range value</li> <li>step_increment: value to increment/decrement when pressing mouse button 1 on a button</li> <li>page_increment: value to increment/decrement when pressing mouse button 2 on a button</li> <li>page_size: unused</li> </ul>
The argument order for the W(Adjustment) constructor is: value, lower, upper, step_increment, page_increment, page_size
GTK2.SpinButton(GTK2.Adjustment(),0.1, 1 )->set_size_request(60,20)
![]()
Properties: GTK2.Adjustment adjustment float climb-rate int digits int numeric int snap-to-ticks int update-policy float value int wrap
Style properties: int shadow-type
Signals: change_value
input
output
value_changed
inherit GTK2.Entry : Entry
inherit GTK2.CellEditable : CellEditable
inherit GTK2.Editable : Editable
GTK2.SpinButton configure(GTK2.Adjustment range, float climb_rate, int precision)
Adjustment (with the lower/upper/increse values), climb_rate and digits
GTK2.SpinButton GTK2.SpinButton(GTK2.Adjustment range_or_min_or_props, float climb_rate_or_max, int|float precision_or_step)
The climb_rate argument take a value between 0.0 and 1.0 and indicates the amount of acceleration that the Spin Button has. The digits argument specifies the number of decimal places to which the value will be displayed.
GTK2.Adjustment get_adjustment()
Get the adjustment associated with this spinbutton.
int get_digits()
Fetches the precision.
int get_entry()
Returns W(Entry) of this widget.
mapping get_increments()
Gets the current step and page increments.
int get_numeric()
Returns whether non-numeric text can be typed in.
mapping get_range()
Gets the range allowed.
int get_snap_to_ticks()
Returns whether the value are corrected to the nearest step.
int get_update_policy()
Gets the update behavior.
float get_value()
Get the value.
int get_value_as_int()
The current value of a Spin Button can be retrieved as a int.
int get_wrap()
Returns whether the value wraps around to the opposite limit when the upper or lower limit of the range is exceeded.
GTK2.SpinButton set_adjustment(GTK2.Adjustment range)
Set a new adjustment.
GTK2.SpinButton set_digits(int precision)
Set the number of digits to show to the user.
GTK2.SpinButton set_increments(float step, float page)
Sets the step and page increments. This affects how quickly the value changes when the arrows are activated.
GTK2.SpinButton set_numeric(int numericp)
If true, it is a numeric value. This prevents a user from typing anything other than numeric values into the text box of a Spin Button
GTK2.SpinButton set_range(float min, float max)
Sets the minimum and maximum allowable values.
GTK2.SpinButton set_snap_to_ticks(int snapp)
Set the Spin Button to round the value to the nearest step_increment, which is set within the Adjustment object used with the Spin Button
GTK2.SpinButton set_update_policy(int policy)
The possible values of policy are either GTK2.UpdateAlways or GTK2.UpdateIfValid.
These policies affect the behavior of a Spin Button when parsing inserted text and syncing its value with the values of the Adjustment.
In the case of GTK2.UpdateIfValid the Spin Button value only gets changed if the text input is a numeric value that is within the range specified by the Adjustment. Otherwise the text is reset to the current value.
In case of GTK2.UpdateAlways errors are ignored while converting text into a numeric value.
GTK2.SpinButton set_value(float to)
Set the value.
GTK2.SpinButton set_wrap(int wrapp)
If true, the spin button will wrap from the lowest to the highest value, and the highest to the lowest.
GTK2.SpinButton spin(int direction, float increment)
If you want to alter the value of a Spin Value relative to its current value, then this function can be used.
The direction paramenter is one of SPIN_END , SPIN_HOME , SPIN_PAGE_BACKWARD , SPIN_PAGE_FORWARD , SPIN_STEP_BACKWARD , SPIN_STEP_FORWARD and SPIN_USER_DEFINED
GTK2.SpinStepForward and GTK2.SpinStepBackward change the value of the Spin Button by the amount specified by increment, unless increment is equal to 0, in which case the value is changed by the value of step_increment in theAdjustment.
GTK2.SpinPageForward and GTK2.SpinPageBackward simply alter the value of the Spin Button by increment.
GTK2.SpinHome sets the value of the Spin Button to the bottom of the Adjustments range.
GTK2.SpinEnd sets the value of the Spin Button to the top of the Adjustments range.
GTK2.SpinUserDefined simply alters the value of the Spin Button by the specified amount.
GTK2.SpinButton update()
Explicitly request that the Spin Button updates itself
| CLASS GTK2.MenuBar |
Basically a horizontal W(Menu).
The menu image cannot be
grabbed automatically, but this is how you would create a menu all
in one line. This is not the recommended coding style.
GTK2.MenuBar()->add(GTK2.MenuItem("Menu")->set_submenu(GTK2.Menu()->add(GTK2.MenuItem("Sub")))->select()->activate())->add(GTK2.MenuItem("Bar"))
![]()
Properties: int child-pack-direction int pack-direction
Style properties: int internal-padding int shadow-type
inherit GTK2.MenuShell : MenuShell
GTK2.MenuBar GTK2.MenuBar(mapping|void props)
Create a new menu bar.
int get_child_pack_direction()
Retrieves the current child pack direction.
int get_pack_direction()
Retrieves the current pack direction of the menubar.
GTK2.MenuBar set_child_pack_direction(int setting)
Sets how widgets should be packed inside the children of a menubar.
GTK2.MenuBar set_pack_direction(int setting)
Sets how items should be packed inside a menubar. One of .
| CLASS GTK2.TextBuffer |
Properties: GTK2.TextTagTable tag_table string text
Signals: apply_tag
begin_user_action
changed
delete_range
end_user_action
insert_child_anchor
insert_pixbuf
insert_text
mark_deleted
mark_set
modified_changed
remove_tag
inherit G.Object : Object
GTK2.TextBuffer add_selection_clipboard(GTK2.Clipboard clipboard)
Adds clipboard to the list of clipboards in which the selection contents of the buffer are available. In most cases, clipboard will be the GTK2.Clipboard of GDK2.SELECTION_PRIMARY for a view of this buffer.
GTK2.TextBuffer apply_tag(GTK2.TextTag tag, GTK2.TextIter start, GTK2.TextIter end)
Emits the "apply-tag" signal. The default handler for the signal applies tag to the given range, start and end do not have to be in order.
GTK2.TextBuffer apply_tag_by_name(string name, GTK2.TextIter start, GTK2.TextIter end)
Calls GTK2.TextTagTable->lookup() on the buffers tag table to get a GTK2.TextTag, then calls apply_tag().
int backspace(GTK2.TextIter iter, int interactive, int default_editable)
Performs the appropriate action as if the user hit the delete key with the cursor at the position specified by iter. In the normal case a single character will be deleted, but when combining accents are involved, more than one character can be deleted, and when precomposed character and accent combinations are involved, less than one character will be deleted.
Because the buffer is modified, all outstanding iterators become invalid after calling this function; however, iter will be re-initialized to point to the location where text was deleted.
GTK2.TextBuffer begin_user_action()
Called to indicate that the buffer operations between here and call end_user_action() are part of a single user-visible operation. The operations between begin_user_action() and end_user_action() can then be grouped when creating an undo stack. W(TextBuffer) maintains a count of calls to begin_user_action() that have not been closed with a call to end_user_action(), and emits the "begin-user-action" and "end-user-action" signals only for the outermost pair of calls. This allows you to build user actions from other user actions.
The "interactive" buffer mutation functions, such as insert_interactive(), automatically call begin/end user action around the buffer operations they perform, so there's no need to add extra calls if your user action consists solely of a single call to one of those functions.
GTK2.TextBuffer copy_clipboard(GTK2.Clipboard clipboard)
Copies the currently-selected text to a clipboard.
GTK2.TextBuffer GTK2.TextBuffer(GTK2.TextTagTable table_or_props)
Creates a new text buffer.
GTK2.TextChildAnchor create_child_anchor(GTK2.TextIter iter)
This is a convenience function which simply creates a child anchor with GTK2.TextChildAnchor->create() and inserts it into the buffer with insert_child_anchor(). The new anchor is owned by the buffer; no reference count is returned.
GTK2.TextMark create_mark(GTK2.TextIter where, int left_gravity, string|void mark_name)
Creates a mark at position where. If mark_name is omitted, the mark is anonymous; otherwise, the mark can be retrieve by name using get_mark(). If a mark has left gravity, and text is inserted at the mark's current location, the mark will be moved to the left of the newly-inserted text. If the mark has right gravity, the mark will end up on the right of the newly-inserted text. The standard left-to-right cursor is a mark with right gravity (when you type, the cursor stays on the right side of the text you're typing). Emits the "mark-set" signal as notification of the mark's initial placement.
GTK2.TextTag create_tag(string tag_name, mapping props)
Creates a tag and adds it to the tag table. Equivalent to calling GTK2.TextTag->create() and then adding the tag to the tag table. The returned tag is owned by the tag table.
GTK2.TextBuffer cut_clipboard(GTK2.Clipboard clipboard, int default_editable)
Copies the currently-selected text to a clipboard, then deletes said text if it's editable.
GTK2.TextBuffer delete(GTK2.TextIter start, GTK2.TextIter end)
Deletes text between start and end. The order of start and end is not actually relevant; delete() will reorder them. This function actually emits the "delete-range" signal, and the default handler of that signal deletes the text. Because the buffer is modified, all outstanding iterators become invalid after calling this function; however, start and end will be re-initialized to point to the location where text was deleted.
int delete_interactive(GTK2.TextIter start, GTK2.TextIter end, int default_editable)
Deletes all editable text in the given range. Calls delete() for each editable sub-range of [start,end). start and end are revalidated to point to the location of the last deleted range, or left untouched if no text was deleted.
GTK2.TextBuffer delete_mark(GTK2.TextMark mark)
Deletes mark, so that it's no longer located anywhere in the buffer. Removes the reference the buffer holds to the mark. There is no way to undelete a mark. The "mark-deleted" signal will be emitted as notification after the mark is deleted.
GTK2.TextBuffer delete_mark_by_name(string name)
Deletes the mark named name; the mark must exist.
int delete_selection(int interactive, int default_editable)
Deletes the range between the "insert" and "selection_bound" marks, that is, the currently-selected text. If interactive is true, the editability of the selection will be considered (users can't delete uneditable text).
GTK2.TextBuffer end_user_action()
Should be paired with begin_user_action();
array get_bounds()
Retrieves the first and last iterators in the buffer, i.e. the entire buffer lies within the range [start,end).
int get_char_count()
Gets the number of characters in the buffer; note that characters and bytes are not the same, you can't e.g. expect the contents of the buffer in string form to be this many bytes long.
GTK2.TextIter get_end_iter()
Returns the "end iterator", one past the last valid character in the buffer. If dereferenced with W(TextIter)->get_char(), the end iterator has a character value of 0. The entire buffer lies in the range from the first position in the buffer to the end iterator.
GTK2.TextMark get_insert()
Returns the mark that represents the cursor (insertion point). Equivalent to calling get_mark() to get the mark named "insert", but very slightly more efficient, and involves less typing.
GTK2.TextIter get_iter_at_child_anchor(GTK2.TextChildAnchor anchor)
Returns the location of anchor.
GTK2.TextIter get_iter_at_line(int line)
Returns a W(TextIter) to the start of the given line.
GTK2.TextIter get_iter_at_line_index(int line, int byte_index)
Obtains an iterator point to byte_index with the given line. byte_index must be the start of a UTF-8 character, and must not be beyond the end of the line. Note bytes, not characters; UTF-8 may encode one character as multiple bytes.
GTK2.TextIter get_iter_at_line_offset(int line_number, int char_offset)
Obtains an iterator pointing to char_offset within the given line. The char_offset must exist, offsets off the end of the line are not allowed. Note characters, not bytes; UTF-8 may encode one character as multiple bytes.
GTK2.TextIter get_iter_at_mark(GTK2.TextMark mark)
Returns an iterator with the current position of mark.
GTK2.TextIter get_iter_at_offset(int offset)
Returns an iterator at position offset chars from the start of the entire buffer. If offset is -1 or greater than the number of characters in the buffer, returns the end iterator, the iterator one past the last valid character in the buffer.
int get_line_count()
Obtains the number of lines in the buffer.
GTK2.TextMark get_mark(string name)
Returns the mark named name.
int get_modified()
Indicates whether the buffer has been modified since the last call to set_modified() set the modification flag to false. Used for example to enable a "save" function in a text editor.
GTK2.TextMark get_selection_bound()
Returns the mark that represents the selection bound. Equivalent to calling get_mark() to get the mark named "selection_bound", but very slightly more efficient, and involves less typing.
The currently-selected text in the buffer is the region between the "selection_bound" and "insert" marks. If "selection_bound" and "insert" are in the same place, then there is no current selection. get_selection_bounds() is another convenient function for handling the selection, if you just want to know whether there's a selection and what its bounds are.
array get_selection_bounds()
Returns either a start and end W(TextIter) if some text is selected, or 2 0's.
string get_slice(GTK2.TextIter start, GTK2.TextIter end, int include_hidden_chars)
Returns the text in the range [start,end). Excludes undisplayed text (text marked with tags that set the invisibility attribute) if include_hidden_chars is false. The returned string includes a 0xFFFC character whenever the buffer contains embedded images, so byte and character indexes into the returned string do correspond to byte and character indexes into the buffer. Contrast with get_text(). Note that 0xFFFC can occur in normal text as well, so it is not a reliable indicator that a pixbuf or widget is in the buffer.
GTK2.TextIter get_start_iter()
Returns an iterator with the first position in the text buffer. This is the same as using get_iter_at_offset() to get the iter at character offset 0.
GTK2.TextTagTable get_tag_table()
Get the W(TextTagTable) associated with this buffer.
string get_text(GTK2.TextIter start, GTK2.TextIter end, int include_hidden_chars)
Returns the text int the range [start,end). Excludes undisplayed text (text marked with tags that set the invisibility attribute) if include_hidden_chars is false. Does not include characters representing embedded images, so byte and character indexes into the returned string do not correspond to byte and character indexes into the buffer. Contrast with get_slice().
GTK2.TextBuffer insert(GTK2.TextIter iter, string text, int len)
Insert len bytes of text at position iter. If len is -1, string will be inserted in its entirely. Emits the 'insert-text' signal. iter is invalidated after insertion, but the default signal handler revalidates it to point to the end of the inserted text.
GTK2.TextBuffer insert_at_cursor(string text, int len)
Simply calls insert(), using the current cursor position as the insertion point.
GTK2.TextBuffer insert_child_anchor(GTK2.TextIter iter, GTK2.TextChildAnchor anchor)
Inserts a child widget anchor into the buffer at iter. The anchor will be counted as one character in character counts, and when obtaining the buffer contents as a string, will be represented by the Unicode "object replacement character" oxFFFC. Note that the "slice" variants for obtaining portions of the buffer as a string include this character for child anchors, but the "text" variants do not. e.g. see get_slice() and get_text(). Consider create_child_anchor() as a more convenient alternative to this function. The buffer will add a reference to the anchor, so you can unref it after insertion.
int insert_interactive(GTK2.TextIter iter, string text, int len, int default_editable)
Like insert(), but the insertion will not occur if iter is at a non- editable location in the buffer. Usually you want to prevent insertions at ineditable locations if the insertion results from a user action (is interactive).
default_edtibale indicates the editability of text that doesn't have a tag affecting editability applied to it. Typically the result of get_editable() is appropriate here.
int insert_interactive_at_cursor(string text, int len, int default_editable)
Calls insert_interactive() at the cursor position.
GTK2.TextBuffer insert_pixbuf(GTK2.TextIter iter, GTK2.GdkPixbuf pixbuf)
Inserts an image into the text buffer at iter. The image will be counted as one character in character counts, and when obtaining the contents as a string, will be represented by the Unicode "object replacement character" 0xFFFC. Note that the "slice" variants for obtaining portions of the buffer as a string include this character for pixbufs, but the "text" variants do not. e.g. see get_slice() and get_text().
GTK2.TextBuffer insert_range(GTK2.TextIter iter, GTK2.TextIter start, GTK2.TextIter end)
Copies text, tags, and pixbufs between start and end (the order of start and end doesn't matter) and inserts the copy at iter. Used instead of simply getting/inserting text because it preserves images and tags. If start and end are in a different buffer from this buffer, the two buffers must share the same tag table.
Implemented via emissions of the insert-text and apply-tag signals, so expect those.
int insert_range_interactive(GTK2.TextIter iter, GTK2.TextIter start, GTK2.TextIter end, int default_editable)
Same as insert_range(), but does nothing if the insertion point isn't editable. The default_editable parameter indicates whether the text is editable at iter if no tags enclosing iter affect editability.
GTK2.TextBuffer insert_with_tags(GTK2.TextIter iter, string text, int len, array tags)
Inserts text into the buffer at iter, applying the list of tags to the newly-inserted text. Equivalent to calling insert(), then apply_tag() on the insert text; insert_with_tags() is just a convenience function.
GTK2.TextBuffer insert_with_tags_by_name(GTK2.TextIter iter, string text, int len, array tag_names)
Same as insert_with_tags(), but allows you to pass in tag names instead of tag objects.
GTK2.TextBuffer move_mark(GTK2.TextMark mark, GTK2.TextIter where)
Moves mark to the new location where. Emits the "mark-set" signal as notification of the move.
GTK2.TextBuffer move_mark_by_name(string name, GTK2.TextIter where)
Moves the mark named name (which must exist) to location where.
GTK2.TextBuffer paste_clipboard(GTK2.Clipboard clipboard, int|void default_editable, GTK2.TextIter location)
Pastes the contents of a clipboard at the insertion point, or at override_location.
GTK2.TextBuffer place_cursor(GTK2.TextIter where)
This function moves the "insert" and "selection_bound" marks simultaneously. If you move them to the same place in two steps with move_mark(), you will temporarily select a region in between their old and new locations, which can be pretty inefficient since the temporarily-selected region will force stuff to be recalculated. This function moves them as a unit, which can be optimized.
GTK2.TextBuffer remove_all_tags(GTK2.TextIter start, GTK2.TextIter end)
Removes all tags in the range between start and end. Be careful with this function; it could remove tags added in code unrelated to the code you're currently writing. That is, using this function is probably a bad idea if you have two or more unrelated code sections that add tags.
GTK2.TextBuffer remove_selection_clipboard(GTK2.Clipboard clipboard)
Removes a clipboard that was added with add_selection_clipboard().
GTK2.TextBuffer remove_tag(GTK2.TextTag tag, GTK2.TextIter start, GTK2.TextIter end)
Emits the "remove-tag" signal. The default handler for the signal removes all occurrences of tag from the given range. start and end do not have to be in order.
GTK2.TextBuffer remove_tag_by_name(string name, GTK2.TextIter start, GTK2.TextIter end)
Removes a tag. See apply_tag_by_name().
GTK2.TextBuffer select_range(GTK2.TextIter ins, GTK2.TextIter bound)
This function removes the "insert" and "selection_bound" marks simultaneously. If you move them in two steps with move_mark(), you will temporarily select a region in between their old and new locations, which can be pretty inefficient since the temporarily-selected region will force stuff to be recalculated. This function moves them as a unit, which can be optimized.
GTK2.TextBuffer set_modified(int setting)
Used to keep track of whether the buffer has been modified since the last time it was saved. Whenever the buffer is saved to disk, call set_modified(0). When the buffer is modified, it will automatically toggle on the modified bit again. When the modifed bit flips, the buffer emits a "modified-changed" signal.
GTK2.TextBuffer set_text(string text, int len)
Deletes current contents of this buffer, and inserts text instead. If len is -1, text must be nul-terminated. text must be valid UTF-8.
| CLASS GTK2.TreeModelFilter |
Properties: GTK2.TreeModel child-model GTK2.TreePath virtual-root
inherit G.Object : Object
inherit GTK2.TreeModel : TreeModel
inherit GTK2.TreeDragSource : TreeDragSource
GTK2.TreeIter convert_child_iter_to_iter(GTK2.TreeIter child_iter)
Returns an iter pointing to the row in this model that corresponds to the row pointed at by child_iter.
GTK2.TreePath convert_child_path_to_path(GTK2.TreePath child_path)
Converts child_path to a path relative to this model. That is, child_path points to a path in the child mode. The returned path will point to the same row in the sorted model.
GTK2.TreeIter convert_iter_to_child_iter(GTK2.TreeIter sorted_iter)
Returns an iter pointing to the row in this model that corresponds to the row pointed at by sorted_iter.
GTK2.TreePath convert_path_to_child_path(GTK2.TreePath sorted_path)
Converts sorted_path to a path on the child model.
GTK2.TreeModelFilter GTK2.TreeModelFilter(GTK2.TreeModel model, GTK2.TreePath root)
Create a new GTK2.TreeModel, with model as the child model.
GTK2.TreeModelFilter refilter()
Emits "row-changed" for each row in the child model, which causes the filter to re-evaluate whether a row is visible or not.
GTK2.TreeModelFilter set_visible_func(function f, mixed user_data)
Sets the comparison function used when sorting to be f. If the current sort column id of this sortable is the same as column, then the model will sort using this function.
| CLASS GTK2.TreeModel |
The tree interface used by TreeView.
Signals: row_changed
row_deleted
row_has_child_toggled
row_inserted
rows_reordered
int get_column_type(int index)
Returns the type of the column.
int get_flags()
Returns a set of flags supported by this interface.
GTK2.TreeIter get_iter(GTK2.TreePath path)
Returns a valid iterator pointer to path
GTK2.TreeIter get_iter_first()
Get GTK2.TreeIter with the first iterator in the tree ("0").
GTK2.TreeIter get_iter_from_string(string path)
Returns a valid iterator from a path string.
int get_n_columns()
Returns the number of columns suppported by this model.
GTK2.TreePath get_path(GTK2.TreeIter iter)
Returns a GTK2.TreePath from iter.
array get_row(GTK2.TreeIter iter)
Get the row at this iter.
string get_string_from_iter(GTK2.TreeIter iter)
Get string representation of iter.
mixed get_value(GTK2.TreeIter iter, int column)
Get value at column of iter.
GTK2.TreeIter iter_children(GTK2.TreeIter parent)
Get first child of parent.
int iter_has_child(GTK2.TreeIter iter)
Check if iter has children.
int iter_n_children(GTK2.TreeIter iter)
Returns the number of children this iter has.
GTK2.TreeIter iter_next(GTK2.TreeIter iter)
Go to next node.
GTK2.TreeIter iter_nth_child(GTK2.TreeIter parent, int index)
Get the child of parent using the given index. Returns valid GTK2.TreeIter if it exists, or 0. If the index is too big, or parent is invalid, then it returns the index from the root node.
GTK2.TreeIter iter_parent(GTK2.TreeIter child)
Get parent of child, or 0 if none.
GTK2.TreeModel row_changed(GTK2.TreePath path, GTK2.TreeIter iter)
Emit "row-changed" signal.
GTK2.TreeModel row_deleted(GTK2.TreePath path)
Emit "row-deleted" signal.
GTK2.TreeModel row_has_child_toggled(GTK2.TreePath path, GTK2.TreeIter iter)
Emit "row-has-child-toggled" signal.
GTK2.TreeModel row_inserted(GTK2.TreePath path, GTK2.TreeIter iter)
Emit "row-inserted" signal.
| CLASS GTK2.RadioAction |
Properties GTK2.RadioAction group int value
Signals: changed
inherit GTK2.ToggleAction : ToggleAction
GTK2.RadioAction GTK2.RadioAction(string|mapping name_or_props, string|void label, string|void tooltip, string|void stock_id, int|void value)
Creates a new GTK2.ToggleAction object.
int get_current_value()
Obtains the value property of the currently active member.
array get_group()
Returns the list representing the radio group.
GTK2.RadioAction set_group(GTK2.RadioAction member)
Sets the radio group.
| CLASS GTK2.RadioMenuItem |
Exactly like W(RadioButton), but it is an menu item.
GTK2.RadioMenuItem("Menu item")
![]()
Properties:
GTK2.RadioMenuItem group
Signals: group_changed
inherit GTK2.CheckMenuItem : CheckMenuItem
GTK2.RadioMenuItem GTK2.RadioMenuItem(string|mapping title, GTK2.RadioMenuItem groupmember)
object GTK2.RadioMenuItem(string title) - First button (with label) object GTK2.RadioMenuItem()->add(widget) - First button (with widget) object GTK2.RadioMenuItem(title, another_radio_button) - Second to n:th button (with title) object GTK2.RadioMenuItem(0,another_radio_button)->add(widget) - Second to n:th button (with widget)
array get_group()
Returns the group to which the radio menu item belongs.
GTK2.RadioMenuItem set_group(GTK2.RadioMenuItem groupmember)
The argument is another radio menu item to whose group this button should be added to. It is prefereable to use the second argument to the constructor instead, but if you for some reason want to move the button to another group, use this function.
| CLASS GTK2.Label |
A simple text label.
GTK2.Label("A simple text label")
![]()
GTK2.Label("Multi\nline text\nlabel here")

GTK2.Label("Multi\nline text\nlabel here")->set_justify(GTK2.JUSTIFY_LEFT)

GTK2.Label("Multi\nline text\nlabel here")->set_justify(GTK2.JUSTIFY_RIGHT)

Properties: float angle Pango.AttrList attributes int cursor-position int ellipsize int justfy JUSTIFY_CENTER , JUSTIFY_FILL , JUSTIFY_LEFT and JUSTIFY_RIGHT string label int max-width-chars int mnemonic-keyval int mnemonic-widget string pattern int selectable int single-line-mode int use-markup int use-underline int width-chars int wrap
Signals: copy_clipboard
move_cursor
populate_popup
inherit GTK2.Misc : Misc
GTK2.Label GTK2.Label(string|mapping text_or_props)
Creates a new label.
float get_angle()
Gets the angle of rotation for the label.
int get_ellipsize()
Returns the ellipsizing position of the label.
int get_justify()
Returns the justification of the label.
string get_label()
Fetches the text from a label widget including any underlines indicating mnemonics and Pango markup.
GTK2.Pango.Layout get_layout()
Gets the Pango.Layout used to display the label. The layout is useful to e.g. convert text positions to pixel positions, in combination with get_layout_offsets().
mapping get_layout_offsets()
Obtains the coordinates where the label will draw the Pango.Layout representing the text in the label; useful to convert mouse events into coordinates inside the Pango.Layout, e.g. to take some action if some part of the label is clicked. Of course, you will need to create a GTK2.EventBox to receive the events, and pack the label inside it, since labels are a GTK2.NO_WINDOW widget. Remember when using the Pango.Layout functions you need to convert to and from pixels using GTK2.PANGO_SCALE.
int get_line_wrap()
Returns whether lines in the label are automatically wrapped.
int get_max_width_chars()
Retrieves the desired maximum width, in characters.
int get_mnemonic_keyval()
If the label has been set so that is has a mnemonic key, this function returns the keyval used for the mnemonic accelerator. If there is no mnemonic set up it returns GDK_VoidSymbol.
GTK2.Widget get_mnemonic_widget()
Retrieves the target of the mnemonic (keyboard shortcut).
int get_selectable()
Gets the value set by set_selectable().
mapping get_selection_bounds()
Gets the selected range of characters in the label. If there isn't a selection, returns -1 for both start and end.
int get_single_line_mode()
Returns whether the label is in single line mode.
string get_text()
Fetches the text from a label widget, as displayed on the screen. This does not include any embedded underlines indicating mnemonics or Pango markup. (see get_label()).
int get_use_markup()
Returns whether the label's text is interpreted as marked up with the Pango text markup language.
int get_use_underline()
Returns whether an embedded underline in the label indicates a mnemonic.
int get_width_chars()
Retrieves the desired width, in characters.
GTK2.Label select_region(int start_offset, int end_offset)
Selects a range of characters in the label, if the label is selectable. See set_selectable(). If the label is not selectable, this function has no effect. If start_offset or end_offset are -1, then the end of the label will be substituted.
GTK2.Label set_angle(int|float angle)
Sets the angle of rotation for the label. An angle of 90 reads from bottom to top, and angle of 270, from top to bottom. The angle setting for the label is igrnored if the lable is selectable, wrapped, or ellipsized.
GTK2.Label set_ellipsize(int mode)
Sets the mode used to ellipsize (add an ellipsis: "...") to the text if there is not enough space to render the entire string. One of .
GTK2.Label set_justify(int jtype)
Sets the alignment of the lines in the text of the label relative to each other. GTK2.JUSTIFY_LEFT is the default value when the widget is first created. If you instead want to set the alignment of the label as a whole, use set_alignment() instead. set_justify() has no efect on labels containing only a single line. One of JUSTIFY_CENTER , JUSTIFY_FILL , JUSTIFY_LEFT and JUSTIFY_RIGHT .
GTK2.Label set_label(string text)
Sets the text of the label. The label is interpreted as including embedded underlines and/or Pango markup depending on the values of use-underline and use-markup.
GTK2.Label set_line_wrap(int wrap)
Toggles line wrapping within the widget. True makes it break lines if text exceeds the widget's size. False lets the text get cut off by the edge of the widget if it exceeds the widget size.
GTK2.Label set_markup(string text)
Parses text which is marked up with the Pango text markup language, setting the label's text and attribute list based on the parse results.
GTK2.Label set_markup_with_mnemonic(string text)
Parses text which is marked up with the Pango text markup language, setting the label's text and attribute list based on the parse results. If characters in text are preceded by an underscore, they are underline indicating that they represent a keyboard accelerator called a mnemonic.
The mnemonic key can be used to activate another widget, chosen automatically, or explicitly using set_mnemonic_widget().
GTK2.Label set_max_width_chars(int n_chars)
Sets the desired maximum width in characters to n_chars.
GTK2.Label set_mnemonic_widget(GTK2.Widget widget)
If the label has been set so that it has a mnemonic key (using i.e. set_markup_with_mnemonic(), set_text_with_mnemonic(), or the "use_underline" property) the label can be associated with a widget that is the target of the mnemonic. When the label is inside a widget (like a GTK2.Button or GTK2.Notebook tab) it is automatically associated with the correct widget, but sometimes (i.e. when the target is a GTK2.Entry next to the label) you need to set it explicitly using this function.
The target widget will be accelerated by emitting "mnemonic_activate" on it. The default handler for this signal will activate the widget if there are no mnemonic collisions and toggle focus between the colliding widgets otherwise.
GTK2.Label set_pattern(string pattern_string)
A string with either spaces or underscores. It should be of the same length as the text.
When a character in the text has a matching _ in the pattern, the character in the label will be underlined.
GTK2.Label set_selectable(int setting)
Selectable labels allow the user to select text from the label, for copy and past.
GTK2.Label set_single_line_mode(int mode)
Sets whether the label is in single line mode.
GTK2.Label set_text(string text)
Set the text in the label
GTK2.Label set_text_with_mnemonic(string text)
Sets the label's text from the string text. If characters in text are preceded by an underscore, they are underlined indicating that they represent a keyboard accelerator called a mnemonic. The mnemonic key can be used to activate another widget, chose automatically, or explicitly using set_mnemonic_widget().
GTK2.Label set_use_markup(int setting)
Sets whether the text of the label contains markup in Pango's text markup language.
GTK2.Label set_use_underline(int setting)
If true, an underline in the text indicates the next character should be used for the mnemonic accelerator key.
GTK2.Label set_width_chars(int n_chars)
Sets the desired width in characters to n_chars.
| CLASS GTK2.Gnome2Druid |
The GNOME druid is a system for assisting the user with installing a service. It is roughly equivalent in functionality to the "Wizards" available in Windows.
There are two major parts of the druid, the Gnome2.Druid widget, and the set of W(Gnome2.DruidPage) widgets. The Gnome2.Druid widget is the main widget that interacts with the user. It has a Next, a Prev, and a Cancel button, and acts as a container for the pages. It is not a top-level window, so it needs to be put in a W(GTK2.Window) in almost all cases. The W(Gnome2.DruidPage) is a virtual widget, from which all of the actual content of the page inherits from. There are currently three of these available within gnome-libs.
GNOME druids are fairly simple to program with. You start by creating a GnomeDruid into which you put all of your pages. This widget will handle the presentation of the W(GnomeDruidPage) widgets.
You then create all appropriate W(GnomeDruidPage) widgets. There are three implementations of these, although there is no reason why more couldn't be written. They are the W(GnomeDruidPageStart), the W(GnomeDruidPageStandard), and the W(GnomeDruidPageFinish). The W(GnomeDruidPageStandard) acts as a W(Container), and is probably the most commonly used druid page. The other ones, as their names might suggest, are used at the endpoints of the druid. More information on the specific properties of these widgets can be found on their respective pages.
You will need to add the pages to the druid in order for them to appear. The druid itself keeps an internal list of all pages, and using the prepend_page(), append_page(), and insert_page() functions will place them into it.
Properties: int show-finish int show-help
Signals: cancel This signal is emitted when the "cancel" button has been pressed. Note that the current druid page has the option to trap the signal and use it, if need be, preventing this signal from being emitted.
help
inherit GTK2.Container : Container
Gnome2.Druid append_page(GTK2.Gnome2DruidPage page)
This will append a GnomeDruidPage into the internal list of pages that the druid has.
Gnome2.Druid GTK2.Gnome2Druid()
Create a new druid
Gnome2.Druid insert_page(GTK2.Gnome2DruidPage back_page, GTK2.Gnome2DruidPage page)
This will insert page after back_page into the list of internal pages that the druid has. If back_page is not present in the list or is 0, page will be prepended to the list.
Gnome2.Druid prepend_page(GTK2.Gnome2DruidPage page)
This will prepend a GnomeDruidPage into the internal list of pages that the druid has.
Gnome2.Druid set_buttons_sensitive(int back_sensitive, int next_sensitive, int cancel_sensitive, int help_sensitive)
Sets the sensitivity of the druid's control-buttons. If the variables are TRUE, then they will be clickable. This function is used primarily by the actual W(GnomeDruidPage) widgets.
Gnome2.Druid set_page(GTK2.Gnome2DruidPage page)
This will make page the currently showing page in the druid. page must already be in the druid.
Gnome2.Druid set_show_finish(int show_finish)
Sets the text on the last button on the druid. If show_finish is TRUE, then the text becomes "Finish". If show_finish is FALSE, then the text becomes "Cancel".
Gnome2.Druid set_show_help(int show_help)
Sets the "Help" button on the druid to be visible in the lower left corner of the widget, if show_help is true.
| CLASS GTK2.HandleBox |
The contents of a handle box can be 'dragged' out of the box by the user.
The contents will then be placed in a separate window.
GTK2.HandleBox()->add(GTK2.Label("The contents"))
![]()
Properties: int handle-position int shadow int shadow-type int snap-edge int snap-edge-set
Signals: child_attached Called when a new child is added to the box
child_detached Called when a child is removed from the box
inherit GTK2.Bin : Bin
GTK2.HandleBox GTK2.HandleBox(mapping|void props)
Create a new handle box widget.
int get_handle_position()
Get the handle position.
int get_shadow_type()
Get the shadow type.
int get_snap_edge()
Get the snap edge.
GTK2.HandleBox set_handle_position(int pos)
The position of the handle. One of POS_BOTTOM , POS_LEFT , POS_RIGHT and POS_TOP
GTK2.HandleBox set_shadow_type(int shadow_type)
One of SHADOW_ETCHED_IN , SHADOW_ETCHED_OUT , SHADOW_IN , SHADOW_NONE and SHADOW_OUT
GTK2.HandleBox set_snap_edge(int pos)
The edge to snap to. One of POS_BOTTOM , POS_LEFT , POS_RIGHT and POS_TOP , or -1 for unset.
| CLASS GTK2.AccelLabel |
A label for accelerators. Properties: GTK2.Widget accel-widget
inherit GTK2.Label : Label
GTK2.AccelLabel GTK2.AccelLabel(string|mapping text_or_props)
Creates a new W(AccelLabel).
GTK2.Widget get_accel_widget()
Fetches the widget monitored by this accelerator label.
int get_accel_width()
Returns the width needed to display the accelerator key(s). This is used by menus to align all of the W(MenuItem).
int refetch()
Recreates the string representing the accelerator keys. This should not be needed since the string is automatically updated whenever accelerators are added or removed from the associated widget.
GTK2.AccelLabel set_accel_widget(GTK2.Widget accel_widget)
Sets the widget to be monitored.
| CLASS GTK2.TextTag |
Properties: string background int background-full-height int background-full-height-set GDK2.Color background-gdk int background-set GDK2.Pixmap background-stipple int background-stipple-set int direction One of int editable int editable-set string family int family-set string font Pango.FontDescription font-desc string foreground GDK2.Color foreground-gdk int foreground-set GDK2.Pixmap foreground-stipple int foreground-stipple-set int indent int indent-set int invisible int invisible_set int justification One of int justification-set string language; int language-set; int left-margin; int left-margin-set; string name; int pixels-above-lines; int pixels-above-lines-set; int pixels-below-lines; int pixels-below-lines-set; int pixels-inside-wrap; int pixels-inside-wrap-set; int right-margin; int right-margin-set; int rise; int rise-set; float scale; int scale-set; int size; double size-points; int size-set; int stretch; One of PANGO_STRETCH_CONDENSED , PANGO_STRETCH_EXPANDED , PANGO_STRETCH_EXTRA_CONDENSED , PANGO_STRETCH_EXTRA_EXPANDED , PANGO_STRETCH_NORMAL , PANGO_STRETCH_SEMI_CONDENSED , PANGO_STRETCH_SEMI_EXPANDED , PANGO_STRETCH_ULTRA_CONDENSED and PANGO_STRETCH_ULTRA_EXPANDED int stretch-set; int strikethrough; int strikethrough-set; int style; One of PANGO_STYLE_ITALIC , PANGO_STYLE_NORMAL and PANGO_STYLE_OBLIQUE int style-set; Pango.TabArray tabs int tabs-set; int underline; One of PANGO_UNDERLINE_DOUBLE , PANGO_UNDERLINE_ERROR , PANGO_UNDERLINE_LOW , PANGO_UNDERLINE_NONE and PANGO_UNDERLINE_SINGLE int underline-set; int variant; One of PANGO_VARIANT_NORMAL and PANGO_VARIANT_SMALL_CAPS int variant-set; int weight; int weight-set; int wrap-mode; One of int wrap-mode-set;
Signals: event
inherit G.Object : Object
GTK2.TextTag GTK2.TextTag(string|mapping name_or_props)
Creates a new text tag.
int event(GTK2.G.Object event_object, GTK2.GdkEvent event, GTK2.TextIter iter)
Emits the 'event' signal.
int get_priority()
Gets the tag priority.
GTK2.TextTag set_priority(int priority)
Sets the priority. Valid priorities start at 0 and go to 1 less than W(TextTagTable)->get_size().
| CLASS GTK2.TreeDragDest |
int drag_data_received(GTK2.TreePath path, GTK2.SelectionData sel)
Asks to insert a row before the path dest, deriving the contents of the row from the sel. If this dest is outside the tree so that inserting before it is impossible, false will be returned. Also, false may be returned if the new row is not created for some model-specific reason.
int row_drop_possible(GTK2.TreePath path, GTK2.SelectionData sel)
Determines whether a drop is possible before past, at the same depth as path. i.e., can we drop the data in sel at that location. path does not have to exist; the return value will almost certainly be false if the parent of path doesn't exist, though.
| CLASS GTK2.GdkRegion |
Region information.
GDK2.Region GTK2.GdkRegion()
Create a new (empty) region
NOIMG
int equal(GTK2.GdkRegion victim)
Return true if the region used as an argument is equal to the current region. Also available as a==b when a is a region.
GTK2.GdkRegion intersect(GTK2.GdkRegion victim)
Computes the intersection of the given region and the region. Also available as region & region
GDK2.Region offset(int dx, int dy)
Offset(move) the region by dx,dy pixels.
int point_in(int x, int y)
Returns true if the given point resides in the given region
int rect_in(GTK2.GdkRectangle r)
Returns true if the given rectangle resides inside the given region
GDK2.Region shrink(int dx, int dy)
reduces the size of a region by a specified amount. Positive values shrink the size of the region, and negative values expand the region.
GTK2.GdkRegion subtract(GTK2.GdkRegion victim)
Computes the difference of the given region and the region. Also available as region - region
GTK2.GdkRegion union(GTK2.GdkRegion victim)
Computes the union of the given rectangle or region and the region. Also available as region | rectangle, region | region, region + region and region + rectangle.
GTK2.GdkRegion xor(GTK2.GdkRegion victim)
Computes the exlusive or of the given region and the region. Also available as region ^ region
| CLASS GTK2.Viewport |
This is a container that can be scrolled around, but it has no scrollbars.
You can connect scrollbars to it using the adjustment objects.
GTK2.Viewport(GTK2.Adjustment(),GTK2.Adjustment())->set_size_request(100,100)

GTK2.Viewport(GTK2.Adjustment(),GTK2.Adjustment())->set_size_request(100,100)->set_shadow_type(GTK2.SHADOW_ETCHED_IN)

GTK2.Viewport(GTK2.Adjustment(),GTK2.Adjustment())->set_size_request(100,100)->add(GTK2.Label("A label with a very long text on it, it will not fit"))->set_shadow_type(GTK2.SHADOW_ETCHED_IN)

lambda(){ object a1;object v = GTK2.Viewport(a1=GTK2.Adjustment(),GTK2.Adjustment())->set_size_request(100,100)->add(GTK2.Label("A label with a very long text on it, it will not fit"))->set_shadow_type(GTK2.SHADOW_ETCHED_IN);call_out(a1->set_value,0,100.0);return v;}()

Properties: GTK2.Adjustment hadjustment int shadow-type GTK2.Adjustment vadjustment
Signals: set_scroll_adjustments
inherit GTK2.Bin : Bin
GTK2.Viewport GTK2.Viewport(GTK2.Adjustment xscroll_or_props, GTK2.Adjustment yscroll)
Create a new viewport. The adjustments are used to select what part of the viewport to view to the user. They are normally connected to a scrollbar or something similar.
GTK2.Adjustment get_hadjustment()
Return the current horizontal adjustment object
int get_shadow_type()
Get the shadow type. One Of SHADOW_ETCHED_IN , SHADOW_ETCHED_OUT , SHADOW_IN , SHADOW_NONE and SHADOW_OUT
GTK2.Adjustment get_vadjustment()
Return the current vertical adjustment object
GTK2.Viewport set_hadjustment(GTK2.Adjustment xscroll)
Set a new horizontal adjustment object.
GTK2.Viewport set_shadow_type(int type)
Set the shadow style. One of SHADOW_ETCHED_IN , SHADOW_ETCHED_OUT , SHADOW_IN , SHADOW_NONE and SHADOW_OUT
GTK2.Viewport set_vadjustment(GTK2.Adjustment yscroll)
Set a new vertical adjustment object.
| CLASS GTK2.Gnome2CanvasRichText |
Properties: int anchor int cursor-blink int cursor-visible int direction int editable int grow-height float height int indent int justification int left-margin int pixels-above-lines int pixels-below-lines int pixels-inside-wrap int right-margin string text int visible float width int wrap-mode float x float y
Signals: tag_changed
inherit Gnome2.CanvasItem : CanvasItem
GTK2.TextBuffer get_buffer()
Get the text buffer.
Gnome2.CanvasRichText set_buffer(GTK2.TextBuffer buffer)
Set the text buffer.
| CLASS GTK2.Gnome2Appbar |
A bar that GNOME applications put on the bottom of the windows to
display status, progress, hints for menu items or a minibuffer for
getting some sort of response. It has a stack for status messages
GTK2.Gnome2Appbar( 1, 1, GTK2.GNOME_PREFERENCES_USER )->set_progress_percentage( 0.4 );
![]()
Properties: int has-progress int has-status int interactivity
Signals: clear_prompt Emitted when the prompt is cleared. mixed user_data
user_response Emitted when the user hits enter after a prompt. mixed user_data
inherit GTK2.Hbox : Hbox
Gnome2.Appbar clear_prompt()
Remove any prompt.
Gnome2.Appbar clear_stack()
Remove all status messages from appbar, and display default status message (if present).
Gnome2.Appbar GTK2.Gnome2Appbar(int has_progress, int has_status, int interactivity)
Create a new GNOME application status bar. If has_progress is TRUE, a small progress bar widget will be created, and placed on the left side of the appbar. If has_status is TRUE, a status bar, possibly an editable one, is created.
interactivity determines whether the appbar is an interactive "minibuffer" or just a status bar. If it is set to Gnome2.PREFERENCES_NEVER, it is never interactive. If it is set to Gnome2.PREFERENCES_USER we respect user preferences from ui-properties. If it's Gnome2.PREFERENCES_ALWAYS we are interactive whether the user likes it or not. Basically, if your app supports both interactive and not (for example, if you use the gnome-app-util interfaces), you should use Gnome2.PREFERENCES_USER. Otherwise, use the setting you support. Please note that "interactive" mode is not functional now; GtkEntry is inadequate and so a custom widget will be written eventually.
GTK2.ProgressBar get_progress()
Returns GTK2.ProgressBar widget pointer, so that the progress bar may be manipulated further.
string get_response()
Get the response to the prompt, if any.
GTK2.Widget get_status()
Retrieves the statusbar widget.
Gnome2.Appbar pop()
Remove current status message, and display previous status message, if any. It is OK to call this with an empty stack.
Gnome2.Appbar push(string what)
Push a new status message onto the status bar stack, and display it.
Gnome2.Appbar refresh()
Reflect the current state of stack/default. Useful to force a set_status to disappear.
Gnome2.Appbar set_default(string default_status)
What to show when showing nothing else; defaults to "".
Gnome2.Appbar set_progress_percentage(float percentage)
Sets progress bar to the given percentage.
Gnome2.Appbar set_prompt(string prompt, int modal)
Put a prompt in the appbar and wait for a response. When the user responds or cancels, a "user-response" signal is emitted.
Gnome2.Appbar set_status(string status)
Sets the status label without changing widget state; next set or push will destroy this permanently.
| CLASS GTK2.SourceMarker |
GTK2.SourceBuffer get_buffer()
Gets the buffer associated with this marker.
int get_line()
Gets the line number of this marker.
string get_marker_type()
Gets the marker type of this marker.
string get_name()
Gets the name of this marker.
GTK2.SourceMarker next()
Gets the next marker after this.
GTK2.SourceMarker prev()
Gets the previous marker before this.
GTK2.SourceMarker set_marker_type(string type)
Not documented.
| CLASS GTK2.Menu |
A GTK2.Menu is a W(MenuShell) that implements a drop down menu consisting of a list of W(MenuItem) objects which can be navigated and activated by the user to perform application functions.
A GTK2.Menu is most commonly dropped down by activating a W(MenuItem) in a W(MenuBar) or popped up by activating a W(MenuItem) in another GTK2.Menu.
A GTK2.Menu can also be popped up by activating a W(OptionMenu). Other composite widgets such as the W(Notebook) can pop up a GTK2.Menu as well.
Applications can display a GTK2.Menu as a popup menu by calling the popup() function. The example below shows how an application can pop up a menu when the 3rd mouse button is pressed.
GTK2.Menu menu = create_menu();
GTK2.Window window = create_window();
window->signal_connect( "button_press_event", lambda(GTK2.Menu m,
GTK2.Window w,
mapping e ) {
if( e->button == 3 )
menu->popup();
}, menu );
Properties:
int tearoff-state
string tearoff-title
Child properties: int bottom-attach int left-attach int right-attach int top-attach
Style properties: int horizontal-offset int vertical-offset int vertical-padding
Signals: move_scroll
inherit GTK2.MenuShell : MenuShell
GTK2.Menu attach(GTK2.Widget child, int left_attach, int right_attach, int top_attach, int bottom_attach)
Adds a new W(MenuItem) to a (table) menu. The number of 'cells' that an item will occupy is specified by left_attach, right_attach, top_attach, and bottom_attach. These each represent the leftmost, rightmost, uppermost and lower column row numbers of the table.
GTK2.Menu GTK2.Menu(mapping|void props)
Creates a new GTK2.Menu widget.
GTK2.Menu detach()
Detaches the menu from the widget to which it had been attached.
GTK2.AccelGroup get_accel_group()
Gets the W(AccelGroup) which holds global accelerators for the menu.
GTK2.Widget get_active()
Returns the selected menu item from the menu. This is used by the W(OptionMenu).
GTK2.Widget get_attach_widget()
Returns the W(Widget) that the menu is attached to.
array get_for_attach_widget()
Returns a list of the menus which are attached to this widget.
int get_tearoff_state()
Returns whether the menu is torn off.
string get_title()
Returns the title of the menu.
GTK2.Menu popdown()
Removes the menu from the screen.
GTK2.Menu popup(int|void button_pressed_to_show_menu)
The default button is 3.
GTK2.Menu reorder_child(GTK2.Widget child, int position)
Moves a W(MenuItem) to a new position within the GTK2.Menu.
GTK2.Menu reposition()
Repositions the menu according to its position function.
GTK2.Menu set_accel_group(GTK2.AccelGroup accelerators)
Set the W(AccelGroup) which holds global accelerators for the menu.
GTK2.Menu set_accel_path(string accel_path)
Sets an accelerator path for this menu.
GTK2.Menu set_active(int activep)
Selects the specified menu item within the menu. This is used by the W(OptionMenu).
GTK2.Menu set_screen(GTK2.GdkScreen screen)
Sets the screen on which the menu is displayed.
GTK2.Menu set_tearoff_state(int torn_off)
Changes the tearoff state of the menu. A menu is normally displayed as a drop down menu which persists as long as the menu is active. It can also be displayed as a tearoff menu which persists until it is closed or reattached.
GTK2.Menu set_title(string new_title)
Sets the title string for the menu. The title is displayed when the menu is shown as a tearoff menu.
| CLASS GTK2.ToolButton |
Properties that can be notified: icon-widget label label-widget stock-id use-underline
Signals: clicked
inherit GTK2.ToolItem : ToolItem
GTK2.ToolButton GTK2.ToolButton(GTK2.Widget icon, string|void label)
Create a new GTK2.ToolButton. If icon is a string, label should be omitted. If it isn't, it will be ignored. The result will be a button from a stock item, one of STOCK_ABOUT , STOCK_ADD , STOCK_APPLY , STOCK_BOLD , STOCK_CANCEL , STOCK_CDROM , STOCK_CLEAR , STOCK_CLOSE , STOCK_COLOR_PICKER , STOCK_CONNECT , STOCK_CONVERT , STOCK_COPY , STOCK_CUT , STOCK_DELETE , STOCK_DIALOG_AUTHENTICATION , STOCK_DIALOG_ERROR , STOCK_DIALOG_INFO , STOCK_DIALOG_QUESTION , STOCK_DIALOG_WARNING , STOCK_DIRECTORY , STOCK_DISCONNECT , STOCK_DND , STOCK_DND_MULTIPLE , STOCK_EDIT , STOCK_EXECUTE , STOCK_FILE , STOCK_FIND , STOCK_FIND_AND_REPLACE , STOCK_FLOPPY , STOCK_FULLSCREEN , STOCK_GOTO_BOTTOM , STOCK_GOTO_FIRST , STOCK_GOTO_LAST , STOCK_GOTO_TOP , STOCK_GO_BACK , STOCK_GO_DOWN , STOCK_GO_FORWARD , STOCK_GO_UP , STOCK_HARDDISK , STOCK_HELP , STOCK_HOME , STOCK_INDENT , STOCK_INDEX , STOCK_INFO , STOCK_ITALIC , STOCK_JUMP_TO , STOCK_JUSTIFY_CENTER , STOCK_JUSTIFY_FILL , STOCK_JUSTIFY_LEFT , STOCK_JUSTIFY_RIGHT , STOCK_LEAVE_FULLSCREEN , STOCK_MEDIA_FORWARD , STOCK_MEDIA_NEXT , STOCK_MEDIA_PAUSE , STOCK_MEDIA_PLAY , STOCK_MEDIA_PREVIOUS , STOCK_MEDIA_RECORD , STOCK_MEDIA_REWIND , STOCK_MEDIA_STOP , STOCK_MISSING_IMAGE , STOCK_NETWORK , STOCK_NEW , STOCK_NO , STOCK_OK , STOCK_OPEN , STOCK_PASTE , STOCK_PREFERENCES , STOCK_PRINT , STOCK_PRINT_PREVIEW , STOCK_PROPERTIES , STOCK_QUIT , STOCK_REDO , STOCK_REFRESH , STOCK_REMOVE , STOCK_REVERT_TO_SAVED , STOCK_SAVE , STOCK_SAVE_AS , STOCK_SELECT_COLOR , STOCK_SELECT_FONT , STOCK_SORT_ASCENDING , STOCK_SORT_DESCENDING , STOCK_SPELL_CHECK , STOCK_STOP , STOCK_STRIKETHROUGH , STOCK_UNDELETE , STOCK_UNDERLINE , STOCK_UNDO , STOCK_UNINDENT , STOCK_YES , STOCK_ZOOM_100 , STOCK_ZOOM_FIT , STOCK_ZOOM_IN and STOCK_ZOOM_OUT . If icon is a GTK2.Widget, it will be used as the icon, and label will be the label. The label must exists if that is the case.
string get_icon_name()
Returns the name of the themed icon for the tool button.
GTK2.Widget get_icon_widget()
Returns the widget used as the icon widget.
string get_label()
Returns the label used by the tool button, or empty if the tool button doesn't have a label.
GTK2.Widget get_label_widget()
Returns the widget used as the label.
string get_stock_id()
Returns the name of the stock item.
int get_use_underline()
Returns whether underscores in the label property are used as mnemonics on menu items on the overflow menu.
GTK2.ToolButton set_icon_name(string name)
Sets the icon for the tool button from a named themed icon. The "icon-name" property only has an effect if not overridden by non-NULL "label", "icon-widget", and "stock-id" properties.
GTK2.ToolButton set_icon_widget(GTK2.Widget icon_widget)
Sets icon_widget as the widget used as the icon on the button.
GTK2.ToolButton set_label(string label)
Sets label as the label used for the tool button.
GTK2.ToolButton set_label_widget(GTK2.Widget label_widget)
Sets label_widget as the widget used as the label.
GTK2.ToolButton set_stock_id(string stock_id)
Sets the name of the stock item.
GTK2.ToolButton set_use_underline(int use_underline)
If set, an underline in the label property indicates that the next character should be used for the mnemonic accelerator key in the overflow menu.
| CLASS GTK2.Allocation |
inherit GDK2.Rectangle : Rectangle
| CLASS GTK2.Statusbar |
Statusbars are simple widgets used to display a text message. They keep a stack of the messages pushed onto them, so that popping the current message will re-display the previous text message.
In order to allow different parts of an application to use the same statusbar to display messages, the statusbar widget issues Context Identifiers which are used to identify different 'users'. The message on top of the stack is the one displayed, no matter what context it is in. Messages are stacked in last-in-first-out order, not context identifier order.
lambda() {object sb = GTK2.Statusbar();int id = sb->get_context_id("test");sb->push(id,"A message");sb->push(id,"Another message");return sb;}()
![]()
lambda() {object sb = GTK2.Statusbar();int id = sb->get_context_id("test");sb->push(id,"A message");sb->push(id,"Another message");sb->pop(id);return sb;}()
![]()
Properties: int has-resize-grip
Style properties: int shadow-type
Signals: text_popped
text_pushed
inherit GTK2.Hbox : Hbox
GTK2.Statusbar GTK2.Statusbar(mapping|void props)
Create a new statusbar widget
int get_context_id(string context)
Create a new context id (or get the id of an old one). The argument is any string. The return value can be used for ->push() ->pop() and ->remove later on.
int get_has_resize_grip()
Returns whether the statusbar has a resize grip.
GTK2.Statusbar pop(int context)
Remove the topmost message.
int push(int context, string data)
Push a message onto the statusbar. The return value is an id that can be passed to remove later on.
GTK2.Statusbar remove(int context, int id)
Remove the specified message (the message id is the second argument).
GTK2.Statusbar set_has_resize_grip(int setting)
Sets whether the statusbar has a resize grip. TRUE by default.
| CLASS GTK2.Image |
An image is a image object stored in client, not X server, memory. A pixmap, on the other hand, is a image object stored in the X-server. See GDK2.Image and GDK2.Pixmap.
GTK2.Image("tornado_nguyen_big.jpg");
![]()
Properties: string file string icon-name icon-set int icon-size GDK2.Image image GDK2.Pixmap mask GDK2.Pixbuf pixbuf GDK2.PixbufAnimation pixbuf-animation int pixel-size GDK2.Pixmap pixmap string stock int storage-type IMAGE_ANIMATION , IMAGE_EMPTY , IMAGE_ICON_NAME , IMAGE_ICON_SET , IMAGE_IMAGE , IMAGE_PIXBUF , IMAGE_PIXMAP and IMAGE_STOCK
inherit GTK2.Misc : Misc
GTK2.Image clear()
Resets the image to be empty.
GTK2.Image GTK2.Image(string|GdkPixbuf|GdkPixbufAnimation|GdkImage|GdkPixmap|mapping file_or_props, GTK2.GdkBitmap mask_or_size)
Create a new W(Image) from either a file or a GDK2.Pixbuf.
GTK2.GdkPixbufAnimation get_animation()
Gets the GDK2.PixbufAnimation being displayed.
mapping get_icon_name()
Gets the icon name and size.
mapping get_image()
Returns ([ "image":GDK2.Image img, "mask":GDK2.Bitmap mask ])
GTK2.GdkPixbuf get_pixbuf()
Gets the GDK2.Pixbuf being displayed. The storage type of the image must be GTK2.IMAGE_EMPTY or GTK2.IMAGE_PIXBUF).
int get_pixel_size()
Gets the pixel size used for named icons.
mapping get_pixmap()
Gets the pixmap and mask.
mapping get_stock()
Gets the stock icon name and size.
int get_storage_type()
Gets the type of representation being used to store data. If it has no image data, the return value will be GTK2.IMAGE_EMPTY. One of IMAGE_ANIMATION , IMAGE_EMPTY , IMAGE_ICON_NAME , IMAGE_ICON_SET , IMAGE_IMAGE , IMAGE_PIXBUF , IMAGE_PIXMAP and IMAGE_STOCK
GTK2.Image set_from_animation(GTK2.GdkPixbufAnimation anim)
Causes the W(Image) to display the given animation.
GTK2.Image set_from_file(string filename)
Set the image from a file.
GTK2.Image set_from_icon_name(string icon_name, int size)
Sets from an icon name.
GTK2.Image set_from_icon_set(GTK2.IconSet icon_set, int size)
Set this image from an icon set.
GTK2.Image set_from_image(GTK2.GdkImage gdk_image, GTK2.GdkBitmap mask)
Set this image from a GDK2.Image plus optional mask.
GTK2.Image set_from_pixbuf(GTK2.GdkPixbuf pixbuf)
Set image from a pixbuf
GTK2.Image set_from_pixmap(GTK2.GdkPixmap pixmap, GTK2.GdkBitmap mask)
Set this image from a GDK2.Pixmap plus optional mask.
GTK2.Image set_from_stock(string stock_id, int size)
Sets from a stock icon. Sample icon names are GTK2.STOCK_OPEN, GTK2.STOCK_EXIT. Sample stock sizes are GTK2.ICON_SIZE_MENU, GTK2.ICON_SIZE_SMALL_TOOLBAR. If the stock name isn't known, the image will be empty.
GTK2.Image set_pixel_size(int pixel_size)
Sets the pixel size to use for named icons. If the pixel size is set to a value != -1, it is used instead of the icon size set by set_from_icon_name().
| CLASS GTK2.SourceTag |
Properties: string id GTK2.SourceTagStyle tag-style
inherit GTK2.TextTag : TextTag
mapping get_style()
Gets the style associated with this tag.
GTK2.SourceTag set_style(mapping style)
Associates a style with this tag. See GTK2.SourceBuffer->set_bracket_match_style() for format.
| CLASS GTK2.Object |
The basic GTK class. All other GTK classes inherit this class. The only user-callable functions are the signal related ones. Properties: gpointer user-data
Signals: destroy
inherit G.Object : Object
| CLASS GTK2.Expander |
Properties: int expanded string label GTK2.Widget label-widget int spacing int use-markup int use-underline
Style properties: int expander-size int expander-spacing
Signals: activate
inherit GTK2.Bin : Bin
GTK2.Expander GTK2.Expander(string|mapping label)
Create a new GTK2.Expander. Set mnemonic to 1 for a mnemonic expander, otherwise omitting it creates a regular expander.
int get_expanded()
Returns true if the child widget is revealed.
string get_label()
Fetches the text from the label of the expander.
GTK2.Widget get_label_widget()
Retrieves the label widget for the frame.
int get_spacing()
Returns the spacing.
int get_use_markup()
Returns whether the label's text is interpreted as marked up with the Pango text markup language.
int get_use_underline()
Returns whether an embedded underline in the label indicates a mnemonic.
GTK2.Expander set_expanded(int expanded)
Sets the state of the expander. Set to true if you want the child widget to be revealed, and false if you want the child widget to be hidden.
GTK2.Expander set_label(string label)
Sets the text of the label of the expander.
GTK2.Expander set_label_widget(GTK2.Widget label)
Set the label widget for the expander. This is the widget that will appear embedded alongside the expander arrow.
GTK2.Expander set_spacing(int spacing)
Sets the spacing field of the expander, which is the number of pixels to place between the expander and the child.
GTK2.Expander set_use_markup(int use_markup)
Sets whether the text of the label contains markup in Pango's text markup language.
GTK2.Expander set_use_underline(int use_underline)
If true, an underline in the text of the label indicates the next character should be used for the mnemonic accelarator key.
| CLASS GTK2.Hseparator |
Simply creates a horizontal separator. No bells or whistles.
GTK2.Hseparator()->set_size_request(300,3)
![]()
inherit GTK2.Separator : Separator
GTK2.Hseparator GTK2.Hseparator(mapping|void props)
Used to create a new hseparator widget.
| CLASS GTK2.GdkPixbufAnimation |
The GdkPixbufAnimation object. Holds animations, like gifs.
inherit G.Object : Object
GDK2.PixbufAnimation GTK2.GdkPixbufAnimation(string filename)
Create a new PixbufAnimation.
int get_height()
Returns the height of the bounding box.
GTK2.GdkPixbufAnimationIter get_iter()
Get an iterator for displaying an animation. The iterator provides the frames that should be displayed at a given time.
Returns the beginning of the animation. Afterwards you should probably immediately display the pixbuf return by GDK2.PixbufAnimationIter->get_pixbuf(). Then, you should install a timeout or by some other mechanism ensure that you'll update the image after GDK2.PixbufAnimationIter->get_delay_time() milliseconds. Each time the image is updated, you should reinstall the timeout with the new, possibly changed delay time.
To update the image, call GDK2.PixbufAnimationIter->advance().
GTK2.GdkPixbuf get_static_image()
If an animation is really just a plain image (has only one frame), this function returns that image. If the animation is an animation, this function returns reasonable thing to display as a static unanimated image, which might be the first frame, or something more sophisticated. If an animation hasn't loaded any frames yet, this function will return 0.
int get_width()
Returns the width of the bounding box.
int is_static_image()
If the file turns out to be a plain, unanimated image, this function will return true. Use get_static_image() to retrieve the image.
| CLASS GTK2.GdkVisual |
A GdkVisual describes a particular video hardware display format. It includes information about the number of bits used for each color, the way the bits are translated into an RGB value for display, and the way the bits are stored in memory.
inherit G.Object : Object
GDK2.Visual GTK2.GdkVisual(int|void best, int|void depth, int|void type)
If best is false the systems default GDK screen is returned, otherwise the screen that best fulfills the given depth and type. If none is given, the one with most colors is selected.
The requested bit depth, or 0.
The requested visual type.
|
GTK2.GdkScreen get_screen()
Gets the screen to which this visual belongs.
| CLASS GTK2.FontSelectionDialog |
The GtkFontSelectionDialog widget is a dialog box for selecting a font.
To set the font which is initially selected, use set_font_name().
To get the selected font use get_font_name().
To change the text which is shown in the preview area, use set_preview_text().
GTK2.FontSelectionDialog("Select a font")

inherit GTK2.Dialog : Dialog
GTK2.FontSelectionDialog GTK2.FontSelectionDialog(string title)
Create a new font selection dialog with the specified window title
GTK2.Button get_apply_button()
The apply button
GTK2.Button get_cancel_button()
The cancel button
string get_font_name()
Gets the currently-selected font name.
GTK2.Button get_ok_button()
The ok button
string get_preview_text()
Gets the text displayed in the preview area.
int set_font_name(string font)
Sets the currently-selected font.
GTK2.FontSelectionDialog set_preview_text(string text)
Sets the text displayed in the preview area.
| CLASS GTK2.Toolbar |
Toolbars are usually used to group some number of widgets in order to simplify customization of their look and layout. Typically a toolbar consists of buttons with icons, labels and tooltips, but any other widget can also be put inside a toolbar. Finally, items can be arranged horizontally or vertically and buttons can be displayed with icons, labels, or both.
Examples:
lambda(){object t=GTK2.Toolbar( /*GTK2.ORIENTATION_HORIZONTAL, GTK2.TOOLBAR_TEXT*/ );t->append_item( "Button 1", "Tooltip 1", "", GTK2.Frame(), lambda(){},0);t->append_space();t->append_item( "Button 2", "Tooltip 2", "", GTK2.Frame(), lambda(){},0);t->append_item( "Button 3", "Tooltip 3", "", GTK2.Frame(), lambda(){},0);t->append_space();t->append_item( "Button 4", "Tooltip 4", "", GTK2.Frame(), lambda(){},0);t->append_item( "Button 5", "Tooltip 5", "", GTK2.Frame(), lambda(){},0);return t;}()

lambda(){object t=GTK2.Toolbar( /*GTK2.ORIENTATION_VERTICAL, GTK2.TOOLBAR_TEXT*/ );t->append_item( "Button 1", "Tooltip 1", "", GTK2.Frame(), lambda(){},0);t->append_space();t->append_item( "Button 2", "Tooltip 2", "", GTK2.Frame(), lambda(){},0);t->append_item( "Button 3", "Tooltip 3", "", GTK2.Frame(), lambda(){},0);t->append_space();t->append_item( "Button 4", "Tooltip 4", "", GTK2.Frame(), lambda(){},0);t->append_item( "Button 5", "Tooltip 5", "", GTK2.Frame(), lambda(){},0);return t;}()

lambda(){object i=GTK2.GdkImage()->set(Image.Image(20,20)->test());object t=GTK2.Toolbar( /*GTK2.ORIENTATION_HORIZONTAL, GTK2.TOOLBAR_BOTH*/ );t->append_item( "Button 1", "Tooltip 1", "", GTK2.Image(i), lambda(){},0);t->append_space();t->append_item( "Button 2", "Tooltip 2", "", GTK2.Image(i), lambda(){},0);t->append_item( "Button 3", "Tooltip 3", "", GTK2.Image(i), lambda(){},0);t->append_space();t->append_item( "Button 4", "Tooltip 4", "", GTK2.Image(i), lambda(){},0);t->append_item( "Button 5", "Tooltip 5", "", GTK2.Image(i), lambda(){},0);return t;}()

Properties: int orientation int show-arrow int toolbar-style int tooltips
Child properties: int expand int homogeneous
Style properties: int button-relief int internal-padding int shadow-type int space-size int space-style
Signals: orientation_changed
popup_context_menu
style_changed
inherit GTK2.Container : Container
GTK2.Toolbar GTK2.Toolbar(mapping|void props)
Creates a new toolbar.
int get_drop_index(int x, int y)
Returns the position corresponding to the indicated point on the toolbar. This is useful when dragging items to the toolbar: this function returns the position a new item should be inserted.
x and y are in toolbar coordinates.
int get_icon_size()
Retrieves the icon size for the toolbar. One of ICON_SIZE_BUTTON , ICON_SIZE_DIALOG , ICON_SIZE_DND , ICON_SIZE_INVALID , ICON_SIZE_LARGE_TOOLBAR , ICON_SIZE_MENU and ICON_SIZE_SMALL_TOOLBAR .
int get_item_index(GTK2.ToolItem item)
Returns the position of item on the toolbar, starting from 0.
int get_n_items()
Returns the number of items on the toolbar.
GTK2.ToolItem get_nth_item(int n)
Returns the n's item on the toolbar, or empty if the toolbar does not contain an n'th item.
int get_orientation()
Retrieves the current orientation of the toolbar.
int get_relief_style()
Returns the relief style of buttons.
int get_show_arrow()
Returns whether the toolbar has an overflow menu.
int get_style()
Retrieves whether the toolbar has text, icons, or both. One of TOOLBAR_BOTH , TOOLBAR_BOTH_HORIZ , TOOLBAR_ICONS , TOOLBAR_SPACE_EMPTY , TOOLBAR_SPACE_LINE and TOOLBAR_TEXT ;
int get_tooltips()
Retrieves whether tooltips are enabled.
GTK2.Toolbar insert(GTK2.ToolItem item, int pos)
Insert a W(ToolItem) into the toolbar at position pos. If pos is 0 the item is prepended to the start of the toolbar. If pos is negative, the item is appended to the end of the toolbar.
GTK2.Toolbar set_drop_highlight_item(GTK2.ToolItem item, int index)
Highlights the toolbar to give an ide aof what it would like if item was added at the position indicated by index.
The item passed to this function must not be part of any widget hierarchy. When an item is set as drop highlight item it can not be added to any widget hierarchy or used as highlight item for another toolbar.
GTK2.Toolbar set_orientation(int orientation)
Sets whether a toolbar should appear horizontally or vertically. One of ORIENTATION_HORIZONTAL and ORIENTATION_VERTICAL .
GTK2.Toolbar set_show_arrow(int show_arrow)
Sets whether to show an overflow menu when the toolbar doesn't have room for all items on it. If true, items for which there are not room are are available through an overflow menu.
GTK2.Toolbar set_style(int style)
Set the style, one of TOOLBAR_BOTH , TOOLBAR_BOTH_HORIZ , TOOLBAR_ICONS , TOOLBAR_SPACE_EMPTY , TOOLBAR_SPACE_LINE and TOOLBAR_TEXT
GTK2.Toolbar set_tooltips(int enable)
Sets if the tooltips should be active or not.
GTK2.Toolbar unset_style()
Unsets a toolbar style, so that user preferences will be used to determine the toolbar style.
| CLASS GTK2.IconSet |
Iconset. A single icon.
GTK2.IconSet add_source(GTK2.IconSource source)
Icon sets have a list of GTK2.IconSource, which they use as base icons for rendering icons in different states and sizes. Icons are scaled, made to look insensitive, etc. in render_icon(), but GTK2.IconSet needs base images to work with. The base images and when to use them are described by a GTK2.IconSource.
This function copies source, so you can reuse the same source immediately without affecting the icon set.
An example of when you'd use this function: a web browser's "Back to Previous Page" icon might point in a different direciton in Hebrew and in English; it might look different when insensitive; and it might change size depending on toolbar mode (small/large icons). So a single icon set would contain all those variants of the icon, and you might add a separate source for each one.
You should nearly always add a "default" icon source with all fields wildcarded, which will be used as a fallback if no more specific source matches. GTK2.IconSet always prefers more specific icon sources to more generic icon sources. The order in which you add the sources to the icon set does not matter.
GTK2.IconSet copy()
Create a copy.
GTK2.IconSet GTK2.IconSet(GTK2.GdkPixbuf pixbuf)
Create a new GTK2.IconSet. A GTK2.IconSet represents a single icon in various sizes and widget states. It can provide a GDK2.Pixbuf for a given size and state on request, and automatically caches some of the rendered GDK2.Pixbuf objects.
Normally you would use GTK2.Widget->render_icon() instead of using GTK2.IconSet directly. The one case where you'd use GTK2.IconSet is to create application-specific icon sets to place in a GTK2.IconFactory.
array get_sizes()
Obtains a list of icon sizes this icon set can render.
| CLASS GTK2.DrawingArea |
The drawing area is a window you can draw in.
Please note that you must handle refresh and resize events
on your own. Use W(pDrawingArea) for a drawingarea with automatic
refresh/resize handling.
GTK2.DrawingArea()->set_size_request(100,100)

inherit GTK2.Widget : Widget
GTK2.DrawingArea clear(int|void x, int|void y, int|void width, int|void height)
Either clears the rectangle defined by the arguments, of if no arguments are specified, the whole drawable.
GTK2.DrawingArea copy_area(GTK2.GdkGC gc, int xdest, int ydest, GTK2.Widget source, int xsource, int ysource, int width, int height)
Copies the rectangle defined by xsource,ysource and width,height from the source drawable, and places the results at xdest,ydest in the drawable in which this function is called.
GTK2.DrawingArea GTK2.DrawingArea(mapping|void props)
Create a new drawing area.
GTK2.DrawingArea draw_arc(GTK2.GdkGC gc, int filledp, int x1, int y1, int x2, int y2, int angle1, int angle2)
Draws a single circular or elliptical arc. Each arc is specified by a rectangle and two angles. The center of the circle or ellipse is the center of the rectangle, and the major and minor axes are specified by the width and height. Positive angles indicate counterclockwise motion, and negative angles indicate clockwise motion. If the magnitude of angle2 is greater than 360 degrees, it is truncated to 360 degrees.
GTK2.DrawingArea draw_bitmap(GTK2.GdkGC gc, GTK2.GdkBitmap bitmap, int xsrc, int ysrc, int xdest, int ydest, int width, int height)
Draw a GDK2(Bitmap) in this drawable. NOTE: This drawable must be a bitmap as well. This will be fixed in GTK 1.3
GTK2.DrawingArea draw_image(GTK2.GdkGC gc, GTK2.GdkImage image, int xsrc, int ysrc, int xdest, int ydest, int width, int height)
Draw the rectangle specified by xsrc,ysrc+width,height from the GDK2(Image) at xdest,ydest in the destination drawable
GTK2.DrawingArea draw_line(GTK2.GdkGC gc, int x1, int y1, int x2, int y2)
img_begin w = GTK2.DrawingArea()->set_size_request(100,100); delay: g = GDK2.GC(w)->set_foreground( GDK2.Color(255,0,0) ); delay: for(int x = 0; x<10; x++) w->draw_line(g,x*10,0,100-x*10,99); img_end
GTK2.DrawingArea draw_pixbuf(GTK2.GdkGC gc, GTK2.GdkPixbuf pixbuf, int xsrc, int ysrc, int xdest, int ydest, int width, int height)
Draw a GDK2(Pixbuf) in this drawable.
GTK2.DrawingArea draw_pixmap(GTK2.GdkGC gc, GTK2.GdkPixmap pixmap, int xsrc, int ysrc, int xdest, int ydest, int width, int height)
Draw the rectangle specified by xsrc,ysrc+width,height from the GDK2(Pixmap) at xdest,ydest in the destination drawable
GTK2.DrawingArea draw_point(GTK2.GdkGC gc, int x, int y)
img_begin w = GTK2.DrawingArea()->set_size_request(10,10); delay: g = GDK2.GC(w)->set_foreground( GDK2.Color(255,0,0) ); delay: for(int x = 0; x<10; x++) w->draw_point(g, x, x); img_end
GTK2.DrawingArea draw_rectangle(GTK2.GdkGC gc, int filledp, int x1, int y1, int x2, int y2)
img_begin w = GTK2.DrawingArea()->set_size_request(100,100); delay: g = GDK2.GC(w)->set_foreground( GDK2.Color(255,0,0) ); delay: for(int x = 0; x<10; x++) w->draw_rectangle(g,0,x*10,0,100-x*10,99); img_end img_begin w = GTK2.DrawingArea()->set_size_request(100,100); delay: g = GDK2.GC(w); delay: for(int x = 0; x<30; x++) { delay: g->set_foreground(GDK2.Color(random(255),random(255),random(255)) ); delay: w->draw_rectangle(g,1,x*10,0,100-x*10,99); delay: } img_end
GTK2.DrawingArea draw_text(GTK2.GdkGC gc, int x, int y, string text)
y is used as the baseline for the text.
GTK2.DrawingArea set_background(GTK2.GdkColor to)
Set the background color or image. The argument is either a GDK2.Pixmap or a GDK2.Color object.
| CLASS GTK2.GdkGC |
A GC, or Graphics Context, is used for most low-level drawing operations.
As an example, the foreground color, background color, and drawing function is stored in the GC.
NOIMG
inherit G.Object : Object
GDK2.GC copy(GTK2.GdkGC source)
Copy all attributes from the source GC
GDK2.GC GTK2.GdkGC(GTK2.Widget context, mapping|void attributes)
The argument is either a W(Widget) or a GDK2(Drawable) in which the gc will be valid.
GTK2.GdkScreen get_screen()
Gets the screen.
mapping get_values()
Get all (or rather most) values from the GC. Even though GdkGCValues contains a GdkFont object, we won't return this value because GdkFont is deprecated. The Pango methods should be used instead.
GDK2.GC set_background(GTK2.GdkColor color)
Set the background to the specified GDK2.Color.
GDK2.GC set_clip_mask(GTK2.GdkBitmap mask)
Set the clip mask to the specified GDK2.Bitmap
GDK2.GC set_clip_origin(int x, int y)
Set the clip mask origin to the specified point.
GDK2.GC set_clip_rectangle(GTK2.GdkRectangle rect)
Sets the clip mask for a graphics context from a rectangle. The clip mask is interpreted relative to the clip origin.
GDK2.GC set_clip_region(GTK2.GdkRegion rect)
Sets the clip mask for a graphs context from a region. The clip mask is interpreted relative to the clip origin.
GDK2.GC set_dashes(int offset, array dashes)
Sets the way dashed-lines are drawn. Lines will be drawn with alternating on and off segments of the lengths specified in dashes. The manner in which the on and off segments are drawn is determined by the line_style value of the GC.
GDK2.GC set_exposures(int exp)
Sets whether copying non-visible portions of a drawable using this gc generates exposure events for the corresponding regions of the dest drawable.
GDK2.GC set_fill(int fill)
Set the fill method to fill.
GDK2.GC set_foreground(GTK2.GdkColor color)
Set the foreground to the specified GDK2.Color.
GDK2.GC set_function(int fun)
Set the function to the specified one. One of GDK2.Xor, GDK2.Invert and GDK2.Copy.
GDK2.GC set_line_attributes(int line_width, int line_style, int cap_style, int join_style)
Control how lines are drawn. line_style is one of GDK2.LineSolid, GDK2,LineOnOffDash and GDK2.LineDoubleDash. cap_style is one of GDK2.CapNotLast, GDK2.CapButt, GDK2.CapRound and GDK2.CapProjecting. join_style is one of GDK2.JoinMiter, GDK2.JoinRound and GDK2.JoinBevel.
GDK2.GC set_stipple(GTK2.GdkBitmap stipple)
Set the background type. Fill must be GDK_STIPPLED or GDK_OPAQUE_STIPPLED.
GDK2.GC set_subwindow(int draw_on_subwindows)
If set, anything drawn with this GC will draw on subwindows as well as the window in which the drawing is done.
GDK2.GC set_tile(GTK2.GdkPixmap tile)
Set the background type. Fill must be GDK_TILED
GDK2.GC set_ts_origin(int x, int y)
Set the origin when using tiles or stipples with the GC. The tile or stipple will be aligned such that the upper left corner of the tile or stipple will coincide with this point.
| CLASS GTK2.CellRendererProgress |
Properties: string text int value
inherit GTK2.CellRenderer : CellRenderer
GTK2.CellRendererProgress GTK2.CellRendererProgress(mapping|void props)
Create a new W(CellRendererProgress).
| CLASS GTK2.UiManager |
Constructing menus and toolbars from an XML description. Properties: int add-tearoffs string ui
Signals: actions_changed Emitted whenever the actions changes.
add_widget Emitted for each generated menubar and toolbar, but not for generated popup menus.
connect_proxy Emitted after connecting a proxy to an action.
disconnect_proxy Emitted after disconnecting a proxy from an action.
post_activate Emitted just after the action is activated.
pre_activate Emitted just before the action is activated. A UI definition: <ui> <menubar> <menu name="FileMenu" action="FileMenuAction"> <menuitem name="New" action="New2Action" /> <placeholder name="FileMenuAdditions" /> </menu> <menu name="JustifyMenu" action="JustifyMenuAction"> <menuitem name="Left" action="justify-left"/> <menuitem name="Centre" action="justify-center"/> <menuitem name="Right" action="justify-right"/> <menuitem name="Fill" action="justify-fill"/> </menu> </menubar> <toolbar action="toolbar1"> <placeholder name="JustifyToolItems"> <separator/> <toolitem name="Left" action="justify-left"/> <toolitem name="Centre" action="justify-center"/> <toolitem name="Right" action="justify-right"/> <toolitem name="Fill" action="justify-fill"/> <separator/> </placeholder> </toolbar> </ui>
inherit G.Object : Object
GTK2.UiManager add_ui(int merge_id, string path, string name, string action, int type, int top)
Adds a ui element to the current contents.
If type is GTK2.UI_MANAGER_AUTO, GTK2+ inserts a menuitem, toolitem or separator if such an element can be inserted at the place determined by path. Otherwise type must indicate an element that can be inserted at the place determined by path.
int add_ui_from_file(string filename)
Parses a file containing a ui definition.
int add_ui_from_string(string buffer)
Parses a string containing a ui definition and merges it with the current contents. An enclosing >ui< element is added if it is missing.
GTK2.UiManager GTK2.UiManager(mapping|void props)
Creates a new ui manager object.
GTK2.UiManager ensure_update()
Makes sure that all pending updates to the ui have been completed.
GTK2.AccelGroup get_accel_group()
Returns the GTK2.AccelGroup associated with this.
GTK2.Action get_action(string path)
Looks up an action by following a path.
array get_action_groups()
Returns the list of action groups.
int get_add_tearoffs()
Returns whether menus generated by this manager will have tearoff menu items.
array get_toplevels(int types)
Obtains a list of all toplevel widgets of the requested types. Bitwise or of UI_MANAGER_ACCELERATOR , UI_MANAGER_AUTO , UI_MANAGER_MENU , UI_MANAGER_MENUBAR , UI_MANAGER_MENUITEM , UI_MANAGER_PLACEHOLDER , UI_MANAGER_POPUP , UI_MANAGER_SEPARATOR , UI_MANAGER_TOOLBAR and UI_MANAGER_TOOLITEM .
string get_ui()
Creates a ui definition of the merged ui.
GTK2.Widget get_widget(string path)
Looks up a widget by following a path. The path consists of the names specified in the xml description of the ui, separated by '/'. Elements which don't have a name or action attribute in the xml (e.g. >popup<) can be addressed by their xml element name (e.g. "popup"). The root element ("/ui") can be omitted in the path.
Note that the widget found be following a path that ends in a >menu< element is the menuitem to which the menu is attached, not the menu itself.
GTK2.UiManager insert_action_group(GTK2.ActionGroup group, int pos)
Inserts an action group into the list of action groups. Actions in earlier groups hide actions with the same name in later groups.
int new_merge_id()
Returns an unused merge id, suitable for use with add_ui().
GTK2.UiManager remove_action_group(GTK2.ActionGroup group)
Removes an action group from the list of action groups.
GTK2.UiManager remove_ui(int merge_id)
Unmerges the part of the content identified by merge_id.
GTK2.UiManager set_add_tearoffs(int setting)
Sets the "add-tearoffs" property, which controls whether menus generated by this manager will have tearoff menu items.
Note that this only affects regular menus. Generated popup menus never have tearoff menu items.
| CLASS GTK2.Layout |
Properties: GTK2.Adjustment hadjustment int height GTK2.Adjustment vadjustment int width
Child properties: int x int y
Signals: set_scroll_adjustments
inherit GTK2.Container : Container
GTK2.Layout GTK2.Layout(GTK2.Adjustment hadjustment_or_props, GTK2.Adjustment vadjustment)
Creates a new GTK2.Layout.
GTK2.Adjustment get_hadjustment()
Gets the GTK2.Adjustment used for communicaiton between the horizontal scrollbar and this layout. This should only be called after the layout has been placed in a GTK2.ScrolledWindow or otherwise configured for scrolling.
GTK2.Adjustment get_vadjustment()
Gets the vertical GTK2.Adjustment.
GTK2.Layout move(GTK2.Widget widget, int x, int y)
Moves a current child to a new position.
GTK2.Layout put(GTK2.Widget widget, int x, int y)
Adds widget to the layout at position (x,y). The layout becomes the new parent.
GTK2.Layout set_hadjustment(GTK2.Adjustment adj)
Sets the horizontal scroll adjustment for the layout.
GTK2.Layout set_size(int xsize, int ysize)
Sets the size of the scrollable area of the layout.
GTK2.Layout set_vadjustment(GTK2.Adjustment adj)
Sets the vertical scroll adjustment for the layout.
| CLASS GTK2.SourcePrintJob |
Properties: GTK2.SourceBuffer buffer Gnome.PrintConfig config string font Pango.FontDescription font-desc string header-footer-font Pango.FontDescription header-footer-font-desc int highlight string numbers-font Pango.FontDescript numbers-font-desc int print-footer int print-header int print-numbers int tabs-width int wrap-mode
Signals: begin_page
finished
inherit G.Object : Object
GTK2.SourcePrintJob cancel()
Cancels an asynchronous printing operation. This will remove any pending print idle handler.
GTK2.SourcePrintJob GTK2.SourcePrintJob(GTK2.SourceBuffer buffer)
Creates a new print job object.
GTK2.SourceBuffer get_buffer()
Gets the GTK2.SourceBuffer the print job would print.
int get_highlight()
Determines if the job is configured to print the text highlighted with colors and font styles. Note that highlighting will happen only if the buffer to print has highlighting activated.
int get_page()
Determines the currently printing page number.
int get_page_count()
Determines the total number of pages the job will print. The returned value is only meaningful after pagination has finished. In practice, for synchronous printing this means when "begin_page" is emitted, or after print_range_async() has returned.
int get_print_footer()
Determines if a footer is set to be printed for each page. A footer will be printed if this function returns true and some format strings have been specified with set_footer_format().
int get_print_header()
Determines if a header is set to be printed for each page. A header will be printed if this function returns true and some format strings have been specified with set_header_format().
int get_print_numbers()
Determines the interval used for line number printing. If the value is 0, no line numbers will be printed. The default value is 1 (i.e. numbers printed in all lines).
int get_tabs_width()
Determines the configured width (in equivalent spaces) of tabulations. The default value is 8.
mapping get_text_margins()
Determines the user set margins for the job. The default for all four margins is 0.0.
int get_wrap_mode()
Determines the wrapping style for text lines wider than the printable width. The default is no wrapping.
GTK2.SourcePrintJob print()
Print the document.
GTK2.SourcePrintJob print_range(GTK2.TextIter start, GTK2.TextIter end)
Similar to print(), except you can specify a range of text to print. start and end can be in any order.
GTK2.SourcePrintJob print_range_async(GTK2.TextIter start, GTK2.TextIter end)
Starts to print job asynchronously. This function will ready the job for printing and install an idle handler that will render one page at a time.
This function will not return immediately, as only page rendering is done asynchronously. Text retrieval and paginating happens within this function. Also, if highlighting is enabled, the whole buffer needs to be highlighted first.
To get notification when the job has finished, you must connect to the "finished" signal.
GTK2.SourcePrintJob set_buffer(GTK2.SourceBuffer buffer)
Sets the GTK2.SourceBuffer the print job will print. You need to specify a buffer to print, either by the use of this function or by creating the print job with create().
GTK2.SourcePrintJob set_footer_format(string|void left, string|void center, string|void right, int separator)
Like set_header_format(), but for the footer.
GTK2.SourcePrintJob set_header_format(string|void left, string|void center, string|void right, int separator)
Sets strftime like header format strings, to be printed on the left, center and right of the top of each page. The strings may include strftime(3) codes which will be expanded at print time. All strftime() codes are accepted, with the addition of N for the page number and Q for the page count.
separator specifies if a solid line should be drawn to separate the header from the document text.
If 0 is given for any of the three arguments, that particular string will not be printed. For the header to be printed, in addition to specifying format strings, you need to enable header printing with set_print_header().
GTK2.SourcePrintJob set_highlight(int setting)
Sets whether the printed text will be highlighted according to the buffer rules. Both color and font style are applied.
GTK2.SourcePrintJob set_print_footer(int setting)
Sets whether you want to print a footer in each page. The default footer consists of three pieces of text and an optional line separator, configurable with set_footer_format().
Note that be default the footer format is unspecified, and if it's empty it will not be printed, regardless of this setting.
GTK2.SourcePrintJob set_print_header(int setting)
Sets whether you want to print a header in each page. The default header consists of three pieces of text and an optional line separator, configurable with set_header_format().
Note that by default the header format is unspecified, and if it's empty it will not be printed, regardless of this setting.
GTK2.SourcePrintJob set_print_numbers(int interval)
Sets the interval for printed line numbers. If interval is 0 no numbers will be printed. If greater than 0, a number will be printed every interval lines (i.e. 1 will print all line numbers).
GTK2.SourcePrintJob set_tabs_width(int tabs_width)
Sets the width (equivalent spaces) of tabulations for the printed text. The width in printing units will be calculated as the width of a string containing tabs_width spaces of the default font. Tabulation stops are set for the full width of printed text.
GTK2.SourcePrintJob set_text_margins(float top, float bottom, float left, float right)
Sets the four user margins for the print job. These margins are in addition to the document margins provided in the GnomePrintConfig and will not be used for headers, footers, or line numbers (those are calculated separately). You can print in the space allocate by these margins by connecting to the "begin-page" signal. The space is around the printed text, and inside the margins specified in the GnomePrintConfig.
The margin numbers are given in device units. If any of the given values is less than 0, that particular margin is not altered by this function.
GTK2.SourcePrintJob set_wrap_mode(int setting)
Sets the wrap mode for lines of text larger than the printable width.
GTK2.SourcePrintJob setup_from_view(GTK2.SourceView view)
Convenience function to set several configuration options at once, so that the printed output matches view. The options set are buffer (if not set already), tabs width, highlighting, wrap mode and default font.
| CLASS GTK2.CellRenderer |
Properties: string cell-background GDK2.Color cell-background-gdk int cell-background-set int height int is-expanded int is-expander int mode CELL_RENDERER_MODE_ACTIVATABLE , CELL_RENDERER_MODE_EDITABLE and CELL_RENDERER_MODE_INERT int sensitive int visible int width float xalign int xpad float yalign int ypad
Signals: editing_canceled
editing_started
inherit GTK2.Data : Data
int activate(GTK2.GdkEvent event, GTK2.Widget widget, string path, GTK2.GdkRectangle background_area, GTK2.GdkRectangle cell_area, int flags)
Passes an activate event to the cell renderer for possible processing. Some cell renderers may use events; for example, W(CellRendererToggle) toggles when it gets a mouse click.
mapping get_fixed_size()
Fills in width and height with the appropriate size of the cell.
mapping get_size(GTK2.Widget widget, GTK2.GdkRectangle cell_area)
Obtains the width and heigh needed to render the cell. Used by widgets to determine the appropriate size for the cell_area passed to render(). If cell_area is present, fills in the x and y offset of the cell relative to this location. Please note that the values set in width and height, as well as those in x_offset and y_offset are inclusive of the xpad and ypad properties.
GTK2.CellRenderer render(GTK2.GdkWindow window, GTK2.Widget widget, GTK2.GdkRectangle background_area, GTK2.GdkRectangle cell_area, GTK2.GdkRectangle expose_area, int flags)
Invokes the virtual render function of the W(CellRenderer). The three passed-in rectangles are areas of window. Most renderers will draw within cell_area; the xalign, yalign, xpad, and ypad fields of the W(CellRenderer) should be honored with respect to cell_area. background_area includes the blank space around the cell, and also the area containing the tree expander; so the background_area rectangles for all cells tile to cover the entire window. expose_area is a clip rectangle. flags is one of CELL_RENDERER_FOCUSED , CELL_RENDERER_INSENSITIVE , CELL_RENDERER_MODE_ACTIVATABLE , CELL_RENDERER_MODE_EDITABLE , CELL_RENDERER_MODE_INERT , CELL_RENDERER_PRELIT , CELL_RENDERER_SELECTED and CELL_RENDERER_SORTED .
GTK2.CellRenderer set_fixed_size(int width, int height)
Sets the renderer size to be explicit, independent of the properties set.
GTK2.CellRenderer start_editing(GTK2.GdkEvent event, GTK2.Widget widget, string path, GTK2.GdkRectangle background_area, GTK2.GdkRectangle cell_area, int flags)
Passes an activate event to the cell renderer for possible processing.
GTK2.CellRenderer stop_editing(int canceled)
Informs the cell renderer that the editing is stopped. If canceled is true, the cell renderer will emit the "editing-canceled" signal. This function should be called by cell renderer implementations in response to the "editing-done" signal of W(CellEditable).
| CLASS GTK2.AboutDialog |
Properties: array(string) artists array(string) authors string comments string copyright array(string) documenters string license GDK2.Pixbuf logo string logo-icon-name string name string translator-credits string version string website string website-label
Style properties: GDK2.Color link-color
inherit GTK2.Dialog : Dialog
GTK2.AboutDialog GTK2.AboutDialog(mapping|void props)
Create a new GTK2.AboutDialog.
array get_artists()
Returns the strings which are displayed in the artists tab of the secondary credits dialog.
array get_authors()
Returns the strings which are displayed in the authors tab of the secondary credits dialog.
string get_comments()
Returns the comments string.
string get_copyright()
Returns the copyright string.
array get_documenters()
Returns the strings which are displayed in the documenters tab of the secondary credits dialog.
string get_license()
Returns the license information.
GTK2.GdkPixbuf get_logo()
Returns the pixbuf displayed as logo.
string get_logo_icon_name()
Returns the icon name.
string get_name()
Returns the program name.
mixed get_property(string property)
Get property.
string get_translator_credits()
Returns the translator credis.
string get_version()
Returns the version string.
string get_website()
Returns the website URL.
string get_website_label()
Returns the label used for the website link.
int get_wrap_license()
Returns whether the license text is automatically wrapped.
GTK2.AboutDialog set_artists(array art)
Sets the strings which are displayed in the artists tab of the secondary credits dialog.
GTK2.AboutDialog set_authors(array auth)
Sets the strings which are displayed in the authors tab of the secondary credits dialog.
GTK2.AboutDialog set_comments(string comments)
Sets the comment string.
GTK2.AboutDialog set_copyright(string copyright)
Sets the copyright string.
GTK2.AboutDialog set_documenters(array doc)
Sets the strings which are displayed in the documenters tab of the secondary credits dialog.
GTK2.AboutDialog set_license(string license)
Sets the license information.
GTK2.AboutDialog set_logo(GTK2.GdkPixbuf logo)
Sets the pixbuf to be displayed as the logo.
GTK2.AboutDialog set_logo_icon_name(string name)
Sets the icon name.
GTK2.AboutDialog set_name(string name)
Sets the name to display.
GTK2.AboutDialog set_translator_credits(string credits)
Sets the translator credits.
GTK2.AboutDialog set_version(string version)
Sets the version string.
GTK2.AboutDialog set_website(string website)
Sets the URL to use for the website link.
GTK2.AboutDialog set_website_label(string label)
Sets the label used for the website link. Defaults to the website URL.
GTK2.AboutDialog set_wrap_license(int setting)
Sets whether the license text is automatically wrapped.
| CLASS GTK2.GdkEvent |
Gdk events.
mixed _index(string ind)
Return an index.
mixed cast(string to)
Cast to different types.
| CLASS GTK2.GdkPixmap |
This class creates a GDK2.Pixmap from either an GDK2.Image or Image.image object (or a numeric ID, see your X-manual for XIDs). The GDK2.Pixmap object can be used in a lot of different GTK widgets. The most notable is the W(Pixmap) widget.
NOIMG
inherit GDK2.Drawable : Drawable
GDK2.Pixmap GTK2.GdkPixmap(int|object image)
Create a new GDK2.Pixmap object. Argument is a GDK2.Image object or a Image.Image object
GDK2.Pixmap ref()
Ref this object.
GDK2.Pixmap set(GTK2.GdkImage image)
Argument is a GDK2.Image object or an Image.image object. It is much faster to use an gdkImage object, especially one allocated in shared memory. This is only an issue if you are going to change the contents of the pixmap often, toggling between a small number of images.
GDK2.Pixmap unref()
Unref this object.
| CLASS GTK2.AccelGroup |
An AccelGroup stores keybindings. A group is automatically created by W(MenuFactory)
NOIMG
Signals: accel_activate
accel_changed
inherit G.Object : Object
GTK2.AccelGroup connect(int accel_key, int accel_mods, int accel_flags, function cb, mixed user_data)
Installs an accelerator in this group.
GTK2.AccelGroup connect_by_path(string accel_path, function cb, mixed user_data)
Installs an accelerator in this group, using an accelerator path to look up the appropriate key and modifiers.
GTK2.AccelGroup GTK2.AccelGroup()
Create a new accelerator group
GTK2.AccelGroup disconnect(int accel_key, int accel_mods)
Removes an accelerator previously installed.
GTK2.AccelGroup lock()
Locks the group.
GTK2.AccelGroup unlock()
Undoes the last call to lock().
| CLASS GTK2.EntryCompletion |
Properties: int inline-completion int minimum-key-length GTK2.TreeModel model int popup-completion int popup-single-match int text-column
Signals: action_activated
insert_prefix
match_selected
inherit G.Object : Object
inherit GTK2.CellLayout : CellLayout
GTK2.EntryCompletion complete()
Requests a completion operation, or in other words a refiltering of the current list with completions, using the current key. The completion list view will be updated accordingly.
GTK2.EntryCompletion GTK2.EntryCompletion(mapping|void props)
Creates a new widget.
GTK2.EntryCompletion delete_action(int index)
Deletes the action at index.
GTK2.Widget get_entry()
Gets the entry this widget has been attached to.
int get_inline_completion()
Returns whether the common prefix of the possible completions should be automatically inserted in the entry.
int get_minimum_key_length()
Returns the minimum key length.
GTK2.TreeModel get_model()
Returns the model being used as the data source.
int get_popup_completion()
Returns whether completions should be presented in a popup window.
int get_popup_set_width()
Returns whether the completion popup window will be resized to the width of the entry.
int get_popup_single_match()
Returns whether the completion popup window will appear even if there is only a single match.
int get_text_column()
Returns the column in the model to get strings from.
GTK2.EntryCompletion insert_action_markup(int index, string markup)
Inserts an action in the action item list at position index with the specified markup.
GTK2.EntryCompletion insert_action_text(int index, string text)
Inserts an action in the action item list at position index with the specified text. If you want the action item to have markup, use insert_action_markup().
GTK2.EntryCompletion insert_prefix()
Requests a prefix insertion.
GTK2.EntryCompletion set_inline_completion(int inline_completion)
Sets whether the common prefix of the possible completions should be automatically inserted in the entry.
GTK2.EntryCompletion set_minimum_key_length(int length)
Requires the length of the search key to be at least length long. This is useful for long lists, where completing using a small key takes a lot of time and will come up with meaningless results anyway (i.e. a too large dataset).
GTK2.EntryCompletion set_model(GTK2.TreeModel model)
Sets the model. If this completion already has a model set, it will remove it before setting the new model. If omitted it will unset the model.
GTK2.EntryCompletion set_popup_completion(int setting)
Sets whether the completions should be presented in a popup window.
GTK2.EntryCompletion set_popup_set_width(int setting)
Sets whether the completion popup window will be resized to be the same width as the entry.
GTK2.EntryCompletion set_popup_single_match(int setting)
Sets whether the completion popup window will appear even if there is only a single match. You may want to set this to 0 if you are using inline completion.
GTK2.EntryCompletion set_text_column(int column)
Convenience function for setting up the most used case of this code: a completion list with just strings. This function will set up the completion to have a list displaying all (and just) strings in the list, and to get those strings from column column in the model.
| CLASS GTK2.Container |
The basic container class. Properties: int border-width GTK2.Widget child int resize-mode RESIZE_IMMEDIATE , RESIZE_PARENT and RESIZE_QUEUE
Signals: add Called when a new object is added to the container. (used internally)
check_resize Called when the container needs resizing (used internally)
remove Called when a object is removed from the container (used internally)
set_focus_child
inherit GTK2.Widget : Widget
GTK2.Container add(GTK2.Widget widget)
Add a subwidget to the container. Don't forget to call show() in the subwidget. Some (even most) containers can only contain one child. Calling this function might result in a resize of the container.
GTK2.Container check_resize()
Undocumented
int get_border_width()
Retrieves the border width.
array get_children()
This function returns all children of the container as an array.
array get_focus_chain()
Returns the focus chain.
GTK2.Adjustment get_focus_hadjustment()
Retrieves the horizontal focus adjustment.
GTK2.Adjustment get_focus_vadjustment()
Retrieves the vertical focus adjustment.
int get_resize_mode()
Returns the resize mode.
GTK2.Container remove(GTK2.Widget widget)
Remove a child from the container. The argument is the child to remove. Calling this function might result in a resize of the container.
GTK2.Container resize_children()
Undocumented.
GTK2.Container set_border_width(int width)
Sets the border width.
GTK2.Container set_focus_chain(array focusable_widgets)
Sets a focus chain, overriding the one computer automatically by GTK+.
In principle each widget in the chain should be a descendant of the container, but this is not enforced by this method, since it's allowed to set the focus chain before you pack the widgets, or have a widget in the chain that isn't always packed. The necessary checks are done when the focus chain is actually traversed.
GTK2.Container set_focus_child(GTK2.Widget child)
Emulate a set_focus_child signal. Focus on the specified child.
GTK2.Container set_focus_hadjustment(GTK2.Adjustment adj)
Set the hadjustment used to focus children.
GTK2.Container set_focus_vadjustment(GTK2.Adjustment adj)
Set the vadjustment used to focus children.
GTK2.Container set_reallocate_redraws(int setting)
Sets the reallocate_redraws flag.
GTK2.Container set_resize_mode(int mode)
One of RESIZE_IMMEDIATE , RESIZE_PARENT and RESIZE_QUEUE
| CLASS GTK2.RadioButton |
Radio buttons are similar to check buttons except they are grouped so that only one may be selected/depressed at a time. This is good for places in your application where you need to select from a short list of options. To connect the buttons, use another button in the desired group as the second argument to GTK2.RadioButton().
GTK2.RadioButton("Button");
![]()
Properties: GTK2.RadioButton group
Signals: group_changed
inherit GTK2.CheckButton : CheckButton
GTK2.RadioButton GTK2.RadioButton(string|mapping title, GTK2.RadioButton groupmember, int|void mnemonic)
Normal creation: object GTK2.RadioButton(string title) - First button (with label) object GTK2.RadioButton()->add(widget) - First button (with widget) object GTK2.RadioButton(title, another_radio_button) - Second to n:th button (with title) object GTK2.RadioButton(0,another_radio_button)->add(widget) - Second to n:th button (with widget)
array get_group()
Returns an array of members in this group.
GTK2.RadioButton set_group(GTK2.RadioButton groupmember)
the argument is another radio button to whose group this button should be added to. It is prefereable to use the second argument to the constructor instead, but if you for some reason want to move the button to another group, use this function.
| CLASS GTK2.TreeDragSource |
int drag_data_delete(GTK2.TreePath path)
Asks to delete the row at path, because it was moved somewhere else via drag-and-drop. Returns false if the deletion fails because path no longer exists, or for some model-specific reason.
GTK2.SelectionData drag_data_get(GTK2.TreePath path)
Asks to return a representation of the row at path.
int row_draggable(GTK2.TreePath path)
Asks the source whether a particular row can be used as the source of a DND operation. If the source doesn't implement this interface, the row is assumed draggable.
| CLASS GTK2.Gnome2DruidPageStandard |
Properties: string background GDK2.Color background-gdk int background-set string contents-background GDK2.Color contents-background-gdk int contents-background-set GDK2.Pixbuf logo string logo-background GDK2.Color logo-background-gdk int logo-background-set string title string title-foreground GDK2.Color title-foreground-gdk int title-foreground-set GDK2.Pixbuf top-watermark
inherit Gnome2.DruidPage : DruidPage
Gnome2.DruidPageStandard append_item(string question, GTK2.Widget item, string additional_info)
Convenience function to add a GTK2.Widget to the vbox. This function creates a new contents section that has the question text followed by the item widget and then the additional_info text, all stacked vertically from top to bottom.
The item widget could be something like a set of radio checkbuttons requesting a choice from the user.
Gnome2.DruidPageStandard GTK2.Gnome2DruidPageStandard(string|void title, GTK2.GdkPixbuf logo, GTK2.GdkPixbuf top_watermark)
Construct a new Gnome2.DruidPageStandard.
Gnome2.DruidPageStandard set_background(GTK2.GdkColor color)
Sets the background color of the top section.
Gnome2.DruidPageStandard set_contents_background(GTK2.GdkColor color)
Sets the color of the main contents section's background.
Gnome2.DruidPageStandard set_logo(GTK2.GdkPixbuf logo)
Sets a GDK2.Pixbuf as the logo in the top right corner. If omitted, then no logo will be displayed.
Gnome2.DruidPageStandard set_logo_background(GTK2.GdkColor color)
Sets the background color of the logo.
Gnome2.DruidPageStandard set_title(string title)
Sets the title.
Gnome2.DruidPageStandard set_title_foreground(GTK2.GdkColor color)
Sets the title text to the specified color.
Gnome2.DruidPageStandard set_top_watermark(GTK2.GdkPixbuf watermark)
Sets a GDK2.Pixbuf as the watermark on top of the top strip on the druid. If watermark is omitted, it is reset to the normal color.
| CLASS GTK2.Progress |
Properties: int activity-mode int show-text float text-xalign float text-yalign
inherit GTK2.Widget : Widget
| CLASS GTK2.SizeGroup |
Provides a mechanism for grouping a number of widgets together so they all request the same amount of space. This is typically usefull when you want a column of widgets to have the same size, but you can't use a W(Table) widget.
In detail, the size requiest for each widget in a GTK2.SizeGroup is the maximum of the sizes that would have been requested for each widget in the size group if they were not in the size group. The mode of the size group (see set_mode() determines whether this applies to the horizontal size, the vertical size, or both sizes.
Note that size groups only affect the amount of space requested, not the size that the widgets finally receive. If you want the widgets in a GTK2.SizeGroup to actually be the same size, you need to pack them in such a way that they get the size they request and not more. For example, if you are packing your widgets into a table, you would not include the GTK2.FILL flag.
GTK2.SizeGroup objects are referenced by each widget in the size group, so one you have added all widgets to a GTK2.SizeGroup, you can drop the initial reference to the size group. If the widgets in the size group are subsequently destroyed, then they will be removed from the size group; when allow idgets have been removed, the size group will be freed.
Widgets can be part of multiple size groups; GTK+ will compute the horizontal size of a widget from the horizontal requisition of all widgets that can be reached from the widget by a chain of size groups of type GTK2.SIZE_GROUP_HORIZONTAL or GTK2.SIZE_GROUP_BOTH, and the vertical size from the vertical requisition of all widgets that can be reached from the widget by a chain of size groups of type GTK2.SIZE_GROUP_VERTICAL or GTK2.SIZE_GROUP_BOTH. Properties: int mode The directions in which the size group effects the requested sizes of its componenent widgets.
inherit G.Object : Object
GTK2.SizeGroup add_widget(GTK2.Widget widget)
Adds a widget to the group. In the future, the requisition of the widget will be determined as the maximum of its requisition and the requisition of the other widgets in the size group. Whether this applies horizontally, vertically, or in both directions depends on the mode.
GTK2.SizeGroup GTK2.SizeGroup(int|mapping mode_or_props)
Create a new group.
int get_ignore_hidden()
Returns if invisible widgets are ignored when calculating the size.
int get_mode()
Gets the current mode.
GTK2.SizeGroup remove_widget(GTK2.Widget widget)
Removes a widget.
GTK2.SizeGroup set_ignore_hidden(int setting)
Sets whether invisible widgets should be ignored when calculating the size.
GTK2.SizeGroup set_mode(int mode)
Sets the mode of the size group. One of SIZE_GROUP_BOTH , SIZE_GROUP_HORIZONTAL , SIZE_GROUP_NONE and SIZE_GROUP_VERTICAL . The mode of the size group determines whether the widgets in the size group should all have the same horizontal requisition, all have the same vertical requisition, or should all have the same requisition in both directions.
| CLASS GTK2.CellView |
Properties: string background GDK2.Color background-gdk int background-set
inherit GTK2.Widget : Widget
inherit GTK2.CellLayout : CellLayout
GTK2.CellView GTK2.CellView(string|GdkPixbuf|mapping text, int|void markup)
Create a new W(CellView) widget.
array get_cell_renderers()
Returns the cell renderers which have been added to this view.
GTK2.TreePath get_displayed_row()
Returns a W(TreePath) referring to the currently displayed row. If no row is currently displayed, 0 is returned.
mapping get_size_of_row(GTK2.TreePath path)
Returns width and height of the size needed to display the model row pointed to by path.
GTK2.CellView set_background_color(GTK2.GdkColor color)
Sets the background color.
GTK2.CellView set_displayed_row(GTK2.TreePath path)
Sets the row of the model that is currently displayed. If the path is omitted, then the contents of the cellview "stick" at their last value; this is not normally a desired result, but may be a needed intermediate state if say, the mode becomes temporarily empty.
GTK2.CellView set_model(GTK2.TreeModel model)
Sets the model. If this view already has a model set, it will remove it before setting the new model.
| CLASS GTK2.SeparatorToolItem |
Properties: int draw
inherit GTK2.ToolItem : ToolItem
GTK2.SeparatorToolItem GTK2.SeparatorToolItem(mapping|void props)
Create a new GTK2.SeparatorToolItem.
int get_draw()
Returns whether SeparatorToolItem is drawn as a line, or just a blank
GTK2.SeparatorToolItem set_draw(int draw)
When a SeparatorToolItem is drawn as a line, or just a blank.
| CLASS GTK2.Widget |
The basic widget, inherited (directly or indirectly) by all widgets. Thus, all functions and signals defined in this widget work on all widgets.
One of the most important functions in this class is 'show', it lets GTK2 know that we are done setting the attributes of the widget, and it is ready to be displayed. You may also use hide to make it disappear again. The order in which you show the widgets is not important, but I suggest showing the toplevel window last so the whole window pops up at once rather than seeing the individual widgets come up on the screen as they're formed. The children of a widget (a window is a widget too) will not be displayed until the window itself is shown using the show() function.
Properties: int app-paintable int can-default int can-focus int composite-child int events (GDK2.EventMask) int extension-events (GDK_EXTENSION_EVENTS_ALL , GDK_EXTENSION_EVENTS_CURSOR and GDK_EXTENSION_EVENTS_NONE ) int has-default int has-focus int height-request int is-focus string name int no-show-all GTK2.Container parent int receives-default int sensitive GTK2.Style style int visible int width-request
Style properties: float cursor-aspect-ratio GDK2.Color cursor-color int draw-border string focus-line-pattern int focus-line-width int focus-padding int interior-focus GDK2.Color link-color int scroll-arrow-hlength int scroll-arrow-vlength int separator-height int separator-width GDK2.Color visited-link-color int wide-separators
Signals: accel_closures_changed
button_press_event Called when a mouse button is pressed
button_release_event Called when a mouse button is released
can_activate_accel
child_notify
client_event An event sent by another client application
composited_changed
configure_event The size, position or stacking order of the widget has changed
delete_event Called when the user has requested that the widget should be closed
destroy_event Called when the widget is destroyed
direction_changed
drag_begin Called when the drag is initiated, on the sending side
drag_data_delete Called when the data can be safely deleted (there is no need to use this function in pigtk, it's all handled automatically)
drag_data_get Called on the sending side when the drop is initiated
drag_data_received Called on the receiving side when the drop is finished
drag_drop Called on the receiving side when the drop is initiated
drag_end Called when the drag is finished, on the sending side
drag_leave Called when the mouse leaves the widget while the user is dragging something
drag_motion Called on the receiving side when the cursor is moved over the widget while dragging something
enter_notify_event Calls when the mouse enters the widget
event Called for all events
event_after
expose_event Called when the widget, or a part of the widget, gets an expose event
focus
focus_in_event The keyboard focus has entered the widget
focus_out_event The keyboard focus has left the widget
grab_broken_event
grab_focus
grab_notify
heirarchy_changed
hide Called when the widget is hidden
key_press_event Called when a keyboard key is pressed
key_release_event Called when a keyboard key is released
leave_notify_event Called when the mouse leaves the widget
map Called when the window associated with the widget is mapped
map_event Called just before the 'map' signal
mnemonic_activate
motion_notify_event Called when the mouse is moved inside the widget
no_expose_event
parent_set Called when the parent widget is changed
popup_menu
property_notify_event Called when a property of the GDK window associated with the widget is changed
proximity_in_event
proximity_out_event
realize Called when the widget is realized. Some methods cannot be used until the widget has been realized; if you get assertion errors related to 'w->window' or similar, this is probably the cause.
screen_changed
scroll_event
selection_clear_event
selection_get
selection_notify_event
selection_received
selection_request_event
show Called when the widget is shown
show_help
size_allocate Called when the widget gets the size it should be
size_request Called when the widget should calculate how big it wants to be
state_changed
style_set Called when the style is changed
unmap Called when the window associated with the widget is unmapped
unmap_event Called just before the 'unmap' signal
unrealize Called when the widget is unrealized;
visibility_notify_event The widget has been mapped, unmapped, hidden, or otherwise had it's visibility modified
window_state_event
inherit GTK2.Object : Object
GTK2.Widget APP_PAINTABLE()
Returns if the GTK2.APP_PAINTABLE flag has been set on this widget.
GTK2.Widget CAN_DEFAULT()
Returns if this widget is allowed to receive the default action.
GTK2.Widget CAN_FOCUS()
Returns if this widget is able to handle focus grabs.
GTK2.Widget COMPOSITE_CHILD()
Returns if this widget is a composite child of its parent.
GTK2.Widget DOUBLE_BUFFERED()
Returns if the GTK2.DOUBLE_BUFFERED flag has been set on this widget.
GTK2.Widget DRAWABLE()
Returns if this widget is mapped and visible.
GTK2.Widget FLAGS()
Returns flags.
GTK2.Widget HAS_DEFAULT()
Returns if this widget is currently receiving the default action.
GTK2.Widget HAS_FOCUS()
Returns if this widget has grabbed the focus and no other widget has done so more recently.
GTK2.Widget HAS_GRAB()
Returns if this widget is in the grab_widgets stack, and will be the preferred one for receiving events other than ones of cosmetic value.
GTK2.Widget IS_SENSITIVE()
Returns if this widget is effectively sensitive.
GTK2.Widget MAPPED()
Returns if this widget is mapped.
GTK2.Widget NO_WINDOW()
Returns if this widget doesn't have its own GDK2.Window.
GTK2.Widget PARENT_SENSITIVE()
Returns if the GTK2.PARENT_SENSITIVE flag is set.
GTK2.Widget RC_STYLE()
Returns if the widget's style has been looked up through the rc mechanism.
GTK2.Widget REALIZED()
Returns if this widget is realized.
GTK2.Widget RECEIVES_DEFAULT()
Returns if this widget when focused will receive the default action even if there is a different widget set as default.
GTK2.Widget SAVED_STATE()
Get the saved state.
GTK2.Widget SENSITIVE()
Returns if this widget is sensitive.
GTK2.Widget STATE()
Get the state.
GTK2.Widget TOPLEVEL()
Returns if this is a toplevel widget.
GTK2.Widget VISIBLE()
Returns if this widget is visible.
int activate()
For widgets that can be "activated" (buttons, menu items, etc.) this functions activates them. Activation is what happens when you press Enter on a widget during key navigation.
GTK2.Widget add_accelerator(string accel_signal, GTK2.AccelGroup accel_group, int accel_key, int accel_mods, int accel_flags)
Installs an accelerator in accel_group that causes accel_signal to be emitted if the accelerator is activated. The signal must be of type G_RUN_ACTION.
GTK2.Widget add_events(int events)
Adds the events in the bitfield events to the event mask.
GTK2.Widget add_mnemonic_label(GTK2.Widget label)
Adds a widget to the list of mnemonic lables for this widget. Note the list of mnemonic labels for the widget is cleared when the widget is destroyed, so the caller must make sure to update it's internal state at this point as well, by using a connection to the destroy signal.
mapping allocation()
Returns ([ "x": xoffset, "y":yoffset, "width":xsize, "height":ysize ])
int can_activate_accel(int signal_id)
Determines whether an accelerator that activates the signal signal_id can currently be activated.
GTK2.Widget child_notify(string prop)
Emits a "child-notify" signal for the child property prop.
string class_path()
Same as path() but uses type rather than name.
GTK2.Pango.Context create_pango_context()
Creates a new Pango.Context with the appropriate colormap, font description, and base direction for drawing text for this widget.
GTK2.Pango.Layout create_pango_layout(string text)
Creates a new Pango.Layout with the appropriate colormap, font description, and base direction for drawing text.
GTK2.Widget freeze_child_notify()
Stops emission of "child-notify" signals. The signals are queued until thaw_child_notify() is called on the widget.
GTK2.Clipboard get_clipboard(GDK2.Atom selection)
Returns the clipboard object for the given selection.
string get_composite_name()
Get the composite name.
int get_direction()
Gets the reading direction.
GTK2.GdkDisplay get_display()
Get the GDK2.Display for the toplevel window associated with this widget. This function can only be called after the widget has been added to a widget hierarchy with a GTK2.Window at the top.
int get_events()
Returns the event mask for the widget.
int get_extension_events()
Retrieves the extension events the widget will receive.
GTK2.RcStyle get_modifier_style()
Returns the current modifier style.
string get_name()
Retrieves the name.
int get_no_show_all()
Returns the current value of the "no-show-all" property.
GTK2.Pango.Context get_pango_context()
Gets a Pango.Context with the appropriate colormap, font description, and base direction for this widget.
GTK2.Widget get_parent()
Returns the parent container.
GTK2.GdkWindow get_parent_window()
Get the parent window.
mapping get_pointer()
Obtains the location of the mouse pointer in widget coordinates.
GTK2.GdkWindow get_root_window()
Get the root window.
GTK2.GdkScreen get_screen()
Get the GDK2.Screen from the toplevel window associated with this widget.
GTK2.Settings get_settings()
Gets the settings object holding the settings (global property settings, RC file information, etc) used for this widget.
mapping get_size_request()
Gets the size request that was explicityly set for the widget using set_size_request(). A value of -1 for width or height indices that that dimension has not been set explicityly and the natural requisition of the widget will be used instead. To get the size a widget will actually use, call size_request() instead.
GTK2.Style get_style()
Returns the style.
GTK2.Widget get_toplevel()
This function returns the topmost widget in the container hierarchy this widget is a part of. If this widget has no parent widgets, it will be returned as the topmost widget.
GTK2.Widget grab_default()
Causes this widget to become the default widget.
GTK2.Widget grab_focus()
Causes this widget to have the keyboard focus. This widget must be a focusable widget, such as a GTK2.Entry; something like GTK2.Frame won't work.
int has_screen()
Checks whether there is a GDK2.Screen associated with this widget.
GTK2.Widget hide()
Hide the widget.
GTK2.Widget hide_all()
Hide this widget, and all child widgets.
int hide_on_delete()
Utility function
int is_ancestor(GTK2.Widget ancestor)
Determines whether this widget is somewhere inside ancestor.
int is_focus()
Determines if the widget is the focus widget within its toplevel. (This does not mean that the HAS_FOCUS flag is necessarily set; HAS_FOCUS will only be set if the toplevel widget additionally has the input focus.
array list_mnemonic_lables()
Returns a list of the widgets, normally labels, for which this widget is the target of a mnemonic.
GTK2.Widget map()
Causes this widget to be mapped.
int mnemonic_activate(int group_cycling)
Not documented.
GTK2.Widget modify_base(int state, GTK2.GdkColor color)
Sets the base color of the widget in a particular state. See modify_fg().
GTK2.Widget modify_bg(int state, GTK2.GdkColor color)
Sets the background color of the widget in a particular state. See modify_fg().
GTK2.Widget modify_fg(int state, GTK2.GdkColor color)
Sets the foreground color of the widget in a particular state. state is one of STATE_ACTIVE , STATE_INSENSITIVE , STATE_NORMAL , STATE_PRELIGHT and STATE_SELECTED . color can be omitted to undo the effect of a previous call.
GTK2.Widget modify_font(GTK2.Pango.FontDescription font)
Sets the font.
GTK2.Widget modify_style(GTK2.RcStyle style)
Modifies style values.
GTK2.Widget modify_text(int state, GTK2.GdkColor color)
Sets the text color of the widget in a particular state. See modify_fg().
string path()
Obtains the full path. The path is simply the name of a widget and all its parents in the container hierarchy, separated by periods.
GTK2.Widget queue_draw()
Equivalent to calling queue_draw_area() for the entire area of the widget.
GTK2.Widget queue_draw_area(int x, int y, int width, int height)
Invalidates the rectangular area defined by x,y,width,height by calling GDK2.Window->invalidate_rect() on the widget's window and all its child windows. Once the main loop becomse idle (after the current batch of events has been processed, roughly), the window will receive expose events for the union of all regions that have been invalidated.
GTK2.Widget queue_resize()
This function is only for use in widget implementations. Flags a widget to have its size renegotiated; should be called when a widget for some reason has a new size request. For example, when you change the text in a W(Label), GTK2.Label queues a resize to ensure there's enough space for the new text.
GTK2.Widget queue_resize_no_redraw()
This function works like queue_resize(), except that the widget is not invalidated.
int remove_accelerator(GTK2.AccelGroup accel_group, int accel_key, int accel_mods)
Removes an accelerator.
GTK2.Widget remove_mnemonic_label(GTK2.Widget label)
Removes a widget from the list of mnemonic labels for this widget.
GTK2.GdkPixbuf render_icon(string stock_id, int size, string detail)
A convenience function that uses the theme engine and rc file settings to look up stock_id and render it to a pixbuf. stock_id should be a stock icon ID such as GTK2.STOCK_OPEN or GTK2.STOCK_OK. size should be a size such as GTK2.ICON_SIZE_MENU. detail should be a string that identifies//! the widget or code doing the rendering, so that theme engines can special-case rendering for that widget or code.
The pixels in the returned GDK2.Pixbuf are shared with the rest of the application and should not be modified.
GTK2.Widget reparent(GTK2.Widget new_parent)
Moves a widget from one W(Container) to another.
GTK2.Widget reset_shapes()
Recursively resets the shape on this widget and its descendants.
GTK2.Widget set_accel_path(string accel_path, GTK2.AccelGroup accel_group)
Sets up an accelerator in accel_group so whenever the key binding that is defined for accel_path is pressed, this widget will be activated.
GTK2.Widget set_composite_name(string name)
Sets a widget's composite name.
GTK2.Widget set_direction(int dir)
Sets the reading direction. This direction controls the primary direction for widgets containing text, and also the direction in which the children of the container are packed. The ability to set the direction is present in order so that correct localization into languages with right-to-left reading directions can be done. Generally, applications will let the default reading direction present, except for containers where the containers are arranged in an order that is explicitly visual rather than logical (such as buttons for text justification).
GTK2.Widget set_events(int events)
Sets the event mask for a widget. The event mask determines which events a widget will receive. Keep in mind that different widgets have different default event masks, and by changing the event mask you may disrupt a widget's functionality, so be careful. This function must be called while a widget is unrealized. Consider add_events() for widgets that are already realized, or if you want to preserve the existing event mask. This function can't be used with GTK2.NO_WINDOW widgets; to get events on those widgets, place them inside a GTK2.EventBox and receive events on the event box.
GTK2.Widget set_extension_events(int mode)
Sets the extension events mask to mode. One of GDK_EXTENSION_EVENTS_ALL , GDK_EXTENSION_EVENTS_CURSOR and GDK_EXTENSION_EVENTS_NONE
GTK2.Widget set_flags(int flags)
Set certain flags, such as GTK2.CAN_DEFAULT.
GTK2.Widget set_name(string name)
Widgets can be named, which allows you to refer to them from a gtkrc file. You can apply a style to widgets with a particular name in the gtkrc file.
GTK2.Widget set_no_show_all(int no_show_all)
Sets the "no-show-all" property, which determines whether calls to show_all() and hide_all() will affect this widget.
GTK2.Widget set_parent(GTK2.Widget parent)
Sets the container as the parent of this widget.
GTK2.Widget set_parent_window(GTK2.GdkWindow parent)
Sets a non default parent window for this widget.
GTK2.Widget set_scroll_adjustments(GTK2.Adjustment hadj, GTK2.Adjustment vadj)
For widgets that support scrolling, sets the scroll adjustments. For widgets that don't support scrolling, does nothing. Widgets that don't support scrolling can be scrolled by placing them in a W(Viewport), which does support scrolling.
GTK2.Widget set_sensitive(int sensitive)
Sets the sensitivity. A widget is sensitive is the user can interact with it. Insensitive widgets are "grayed out" and the user can't interact with them. Insensitive widgets are known as "inactive", "disabled", or "ghosted" in some other toolkits.
GTK2.Widget set_size_request(int width, int height)
Sets the minimum size of a widget; that is, the widget's size request will be width by height. You can use this function to force a widget to be either larger or smaller than it normally would be.
In most cases, set_default_size() is a better choice for toplevel windows than this function; setting the default size will still allow users to shrink the window. Setting the size request will force them to leave the window at least as large as the size request. When dealing with window sizes, set_geometry_hints() can be a useful function as well.
Note the inherent danger of setting any fixed size - themes, translations into other languages, different fonts, and user action can all change the appropriate size for a given widget. So, it's basically impossible to hardcode a size that will always be correct.
The size request of a widget is the smallest size a widget can accept while still functioning well and drawing itself correctly. However in some strange cases a widget may be allocated less than its requested size, and in many cases a widget may be allocated more space than it request.
If the size request in a given direction is -1 (unset), then the "natural" size request of the widget will be used instead.
Widgets can't actually be allocated a size less than 1x1, but you can pass 0,0 to this function to mean "as small as possible".
GTK2.Widget set_style(GTK2.Style style)
Sets the style.
GTK2.Widget shape_combine_mask(GTK2.GdkBitmap shape_mask, int offset_x, int offset_y)
Sets a shape for a widget's GDK2.Window. This allows for transparent window, etc.
GTK2.Widget show()
Show the widget. Most (almost all) widgets must be shown to be visible on the screen.
GTK2.Widget show_all()
Show this widget, and all child widgets.
GTK2.Widget show_now()
Shows a widget. If the widget is an unmapped toplevel widget (i.e. a GTK2.Window that has not yet been shown), enter the main loop and wait for the window to actually be mapped. Be careful; because the main loop is running, anything can happen during this function.
mapping size_request()
Get the size allocated to a widget.
mixed style_get_property(string name)
Gets the value of the style property called name.
GTK2.Widget thaw_child_notify()
Reverts the effect of a previous call to freeze_child_notify().
GTK2.Widget unmap()
Causes this widget to be unmapped.
GTK2.Widget unset_flags(int flags)
Unset flags.
| CLASS GTK2.HScrollbar |
A horizontal scrollbar.
General documentation: See W(Scrollbar)
GTK2.HScrollbar(GTK2.Adjustment())->set_size_request(300,15)
![]()
inherit GTK2.Scrollbar : Scrollbar
GTK2.HScrollbar GTK2.HScrollbar(GTK2.Adjustment adjustment_or_props)
Used to create a new hscrollbar widget.
| CLASS GTK2.GdkScreen |
Properties: font-options float resolution
Signals: composite_changed
size_changed
inherit G.Object : Object
GDK2.Screen GTK2.GdkScreen()
Gets the default screen.
GTK2.GdkColormap get_default_colormap()
Gets the default colormap.
GTK2.GdkDisplay get_display()
Gets the display to which this screen belongs.
int get_height()
Gets the height in pixels.
int get_height_mm()
Returns the height in millimeters.
int get_monitor_at_point(int x, int y)
Returns the monitor number in which x,y is located.
int get_monitor_at_window(GTK2.GdkWindow window)
Returns the number of the monitor in which the largest area of the bounding rectangle of window resides.
GTK2.GdkRectangle get_monitor_geometry(int num)
Retrieves the GDK2.Rectangle representing the size and position of the individual monitor within the entire screen area.
int get_n_monitors()
Returns the number of monitors which this screen consists of.
int get_number()
Gets the index of this screen among the screens in the display to which it belongs.
GTK2.GdkColormap get_rgb_colormap()
Gets the preferred colormap for rendering image data.
GTK2.GdkVisual get_rgb_visual()
Get a "preferred visual" chosen by GdkRGB for rendering image data.
GTK2.GdkColormap get_rgba_colormap()
Gets a colormap to use for creating windows or pixmaps with an alpha channel.
GTK2.GdkVisual get_rgba_visual()
Gets a visual to use for creating windows or pixmaps with an alpha channel.
GTK2.GdkWindow get_root_window()
Gets the root window.
GTK2.GdkColormap get_system_colormap()
Gets the system default colormap.
GTK2.GdkVisual get_system_visual()
Get the default system visual.
array get_toplevel_windows()
Returns a list of all toplevel windows known to GDK on the screen.
int get_width()
Gets the width of the screen in pixels.
int get_width_mm()
Gets the width in millimeters.
array list_visuals(int|void def)
List the available visuals. If def is true, return the available visuals for the default screen.
string make_display_name()
Determines the name to pass to GDK2.Display->open() to get a GDK2.Display with this screen as the default screen.
GDK2.Screen set_default_colormap(GTK2.GdkColormap colormap)
Sets the default colormap.
| CLASS GTK2.HbuttonBox |
A HbuttonBox is very similar to a Hbox. The major diffference is that the button box is made to pack buttons in, and has a few convenience function for normal button layouts.
GTK2.HbuttonBox()->add(GTK2.Button("Hello"))->add(GTK2.Button("World"))->set_size_request(400,30)
![]()
GTK2.HbuttonBox()->add(GTK2.Button("Hello"))->add(GTK2.Button("World"))->set_layout(GTK2.BUTTONBOX_SPREAD)->set_size_request(400,30)
![]()
GTK2.HbuttonBox()->add(GTK2.Button("Hello"))->add(GTK2.Button("World"))->set_layout(GTK2.BUTTONBOX_EDGE)->set_size_request(400,30)
![]()
GTK2.HbuttonBox()->add(GTK2.Button("Hello"))->add(GTK2.Button("World"))->set_layout(GTK2.BUTTONBOX_START)->set_size_request(400,30)
![]()
GTK2.HbuttonBox()->add(GTK2.Button("Hello"))->add(GTK2.Button("World"))->set_layout(GTK2.BUTTONBOX_END)->set_size_request(400,30)
![]()
inherit GTK2.ButtonBox : ButtonBox
GTK2.HbuttonBox GTK2.HbuttonBox(mapping|void props)
Create a new horizontal button box
| CLASS GTK2.Pango.TabArray |
inherit G.Object : Object
GTK2.Pango.TabArray copy()
Returns a copy.
Pango.TabArray GTK2.Pango.TabArray(int initial_size, int position_in_pixels)
Creates an array of initial_size tab stops. Tab stops are specified in pixel units if positions_in_pixels is true, otherwise in Pango units. All stops are initially at position 0.
int get_positions_in_pixels()
Returns true if the tab positions are in pixels, false if they are in Pango units.
int get_size()
Gets the number of tab stops.
mapping get_tab(int tab_index)
Gets the alignment and position of a tab stop.
array get_tabs()
Gets alignments and locations of all tab stops.
Pango.TabArray resize(int new_size)
Resizes the array. You must subsequently initialize any tabs that were added as a result of growing the array.
Pango.TabArray set_tab(int tab_index, int alignment, int location)
Sets the alignment and location of a tab stop. Alignment must always be PANGO_TAB_LEFT .
| CLASS GTK2.Misc |
The GTK2.Misc widget is an abstract widget which is not useful itself, but is used to derive subclasses which have alignment and padding attributes.
The horizontal and vertical padding attributes allows extra space to be added around the widget.
The horizontal and vertical alignment attributes enable the widget to be positioned within its allocated area. Note that if the widget is added to a container in such a way that it expands automatically to fill its allocated area, the alignment settings will not alter the widgets position.
GTK2.Vbox(0,0)->add(GTK2.Label("Label"))->set_size_request(100,20)
![]()
GTK2.Vbox(0,0)->add(GTK2.Label("Label")->set_alignment(1.0,0.0))->set_size_request(100,20)
![]()
GTK2.Vbox(0,0)->add(GTK2.Label("Label")->set_alignment(0.0,0.0))->set_size_request(100,20)
![]()
Properties: float xalign The horizontal alignment, from 0 (left) to 1 (right). int xpad The amount of space to add on the left and right of the widget, in pixels. float yalign The vertical alignment, from 0 (top) to 1 (bottom). int ypad The amount of space to add on the top and bottom of the widget, in pixels.
inherit GTK2.Widget : Widget
mapping get_alignment()
Gets the x and y alignment.
mapping get_padding()
Gets the x and y padding.
GTK2.Misc set_alignment(float xalign, float yalign)
Sets the alignment of the widget. 0.0 is left or topmost, 1.0 is right or bottommost.
GTK2.Misc set_padding(int xpad, int ypad)
Sets the amount of space to add around the widget. xpad and ypad are specified in pixels.
| CLASS GTK2.Databox |
GtkDatabox is designed to display large amounts of numerical data fast and easy. Thousands of data points (X and Y coordinate) may be displayed without any problems, zooming and scrolling as well as optional rulers are already included.
The widget may be used as display for oscilloscopes or other applications that need to display fast changes in their data.
GTK2.Databox x=GTK2.Databox(); x->data_add_x_y(3, ({ 1.0, 0.5, 0.0 }), ({1.0, -1.0, 0.0}),GTK2.GdkColor(Image.Color.red), GTK2.DataboxLines,2); x->rescale(); x->set_size_request(300,300); return x;

Signals: marked
selection_canceled
selection_changed
selection_started
selection_stopped
zoomed
inherit GTK2.Vbox : Vbox
GTK2.Databox GTK2.Databox()
Create a new databox widget
int data_add(int nelems, array x, array y, GTK2.GdkColor color, int type, int dot_size)
Type is one of DATABOX_BARS , DATABOX_CROSS_SIMPLE , DATABOX_GRID , DATABOX_LINES , DATABOX_NOT_DISPLAYED and DATABOX_POINTS
GTK2.GdkColor data_get_color(int index)
Get the color at index.
array data_get_extrema()
int data_get_grid_config(int index)
See data_set_grid_config().
array data_get_type(int index)
Return type and dot size at index.
mapping data_get_value(int x, int y)
array data_get_visible_extrema()
int data_remove(int index)
Remove data at index.
int data_remove_all()
Remove all data.
int data_set_color(int index, GTK2.GdkColor color)
int data_set_grid_config(int index, int hlines, int vlines)
Not useful unless the data type is GTK2.DATABOX_GRID.
int data_set_type(int index, int type, int dot_size)
Type is one of DATABOX_BARS , DATABOX_CROSS_SIMPLE , DATABOX_GRID , DATABOX_LINES , DATABOX_NOT_DISPLAYED and DATABOX_POINTS
GTK2.Databox get_rulers_enable()
Get whether rulers will be displayed.
GTK2.Databox get_scrollbars_enable()
Get whether scrollbars will be displayed.
int get_selection_enable()
Get whether selection is enabled.
int get_selection_fill_enable()
Get whether the selection will be filled.
GTK2.Databox get_zoom_enable()
Get whether zoom is enabled.
float get_zoom_limit()
Get the zoom limit.
GTK2.Databox redraw()
Redraw.
GTK2.Databox rescale()
GTK2.Databox rescale_inverted(int invertX, int invertY)
Rescale with an inverted x and/or y direction.
GTK2.Databox rescale_with_values(float minx, float miny, float maxx, float maxy)
GTK2.Databox set_background_color(GTK2.GdkColor color)
Set the background color.
GTK2.Databox set_rulers_enable(int setting)
Set whether rulers will be displayed.
GTK2.Databox set_scrollbars_enable(int setting)
Set whether scrollbars will be displayed.
GTK2.Databox set_selection_enable(int setting)
Set whether selection is enabled.
GTK2.Databox set_selection_fill_enable(int setting)
Set whether the selection will be filled.
GTK2.Databox set_zoom_enable(int setting)
Set whether zoom is enabled.
GTK2.Databox set_zoom_limit(float limit)
Set the zoom limit. Default is 0.01, which is 100 times.
| CLASS GTK2.CellLayout |
An interface for packing cells.
GTK2.CellLayout add_attribute(GTK2.CellRenderer cell, string attribute, int column)
Adds an attribute mapping.
GTK2.CellLayout clear()
Unsets all the mappings on all renderers and removes all renderers.
GTK2.CellLayout clear_attributes(GTK2.CellRenderer cell)
Clears all existing attributes.
GTK2.CellLayout pack_end(GTK2.CellRenderer cell, int expand)
See pack_start().
GTK2.CellLayout pack_start(GTK2.CellRenderer cell, int expand)
Packs the cell into the beginning. If expand is false, then the cell is allocated no more space than it needs. Any unused space is divied evenly between the cells for which expand is true.
GTK2.CellLayout reorder(GTK2.CellRenderer cell, int position)
Re-inserts cell at position.
GTK2.CellLayout set_cell_data_func(GTK2.CellRenderer cell, function f, mixed user_data)
Sets the callback to use for this cell layout. This function is used instead of the standard attributes mapping for setting the column value, and should set the value of the cell layout's cell renderer(s) as appropriate. f may be 0 to remove an older one.
| CLASS GTK2.MessageDialog |
A dialog with an image representing the type of message (Error, Question). alongside some message text. It's simply a convenience widget; you could construct the equivalent of GTK2.MessageDialog from GTK2.Dialog without too much effort, but GTK2.MessageDialog saves typing. Properties: int buttons int message-type
Style properties: int message-border int use-separator
inherit GTK2.Dialog : Dialog
GTK2.MessageDialog GTK2.MessageDialog(mapping|int flags, int|void type, int|void buttons, string|void message, GTK2.Window parent)
Creates a new message dialog, which is a simple dialog with an icon indicating the dialog type (error, warning, etc) and some text the user may want to see. When the user clicks a button a "response" signal is emitted with response IDs from . See GTK2.Dialog for more details.
GTK2.MessageDialog format_secondary_markup(string text)
Sets the secondary text of the message dialog to be text, which is marked up with the Pango text markup language.
Note tha tsetting a secondary text makes the primary text become bold, unless you have provided explicit markup.
GTK2.MessageDialog format_secondary_text(string text)
Sets the secondary text of the message dialog to be text.
Note that setting a secondary text makes the primary text become bold, unless you have provided explicit markup.
GTK2.MessageDialog set_markup(string text)
Sets the text of the message dialog to be text, which is marked up with the Pango text markup language.
| CLASS GTK2.Plug |
Together with W(Socket), GTK2.Plug provides the ability to embed widgets from one process into another process in a fashion that is transparent to the user. One process creates a W(Socket) widget and, passes the XID of that widgets window to the other process, which then creates a GTK2.Plug window with that XID. Any widgets contained in the GTK2.Plug then will appear inside the first applications window.
Signals: embedded
inherit GTK2.Window : Window
GTK2.Plug GTK2.Plug(int|mapping socket_id_or_props)
Create a new plug, the socket_id is the window into which this plug will be plugged.
int get_id()
Gets the window id of this widget.
| CLASS GTK2.ColorSelectionDialog |
Color Selection Dialog
inherit GTK2.Dialog : Dialog
GTK2.ColorSelectionDialog GTK2.ColorSelectionDialog(string|mapping title_or_props)
Create a new Color Selection Dialog
GTK2.Widget get_cancel_button()
The Cancel button.
GTK2.Widget get_colorsel()
The Color Selection widget contained within the dialog
GTK2.Widget get_help_button()
The Help button.
GTK2.Widget get_ok_button()
The OK button.
| CLASS GTK2.Gnome2CanvasClipgroup |
Properties: string path int wind
inherit Gnome2.CanvasGroup : CanvasGroup
| CLASS GTK2.ImageMenuItem |
Properties: GTK2.Widget image
inherit GTK2.MenuItem : MenuItem
GTK2.ImageMenuItem GTK2.ImageMenuItem(string|mapping label)
Create a new ImageMenuItem.
GTK2.Widget get_image()
Gets the widget that is currently set as the image.
GTK2.ImageMenuItem set_image(GTK2.Widget image)
Sets the image of the image menu item.
| CLASS GTK2.FileSelection |
GtkFileSelection should be used to retrieve file or directory names from the user. It will create a new dialog window containing a directory list, and a file list corresponding to the current working directory. The filesystem can be navigated using the directory list, the drop-down history menu, or the TAB key can be used to navigate using filename completion common in text based editors such as emacs and jed.
The default filename can be set using set_filename() and the selected filename retrieved using get_filename().
Use complete() to display files that match a given pattern. This can be used for example, to show only *.txt files, or only files beginning with gtk*.
Simple file operations; create directory, delete file, and rename file, are available from buttons at the top of the dialog. These can be hidden using hide_fileop_buttons() and shown again using show_fileop_buttons().
GTK2.FileSelection("File selector")

Properties: string filename int select-multiple int show-fileops
inherit GTK2.Dialog : Dialog
GTK2.FileSelection complete(string pattern)
Will attempt to match pattern to a valid filename in the current directory. If a match can be made, the matched filename will appear in the text entry field of the file selection dialog. If a partial match can be made, the "Files" list will contain those file names which have been partially matched.
GTK2.FileSelection GTK2.FileSelection(string|mapping title_or_props)
Creates a new file selection dialog box. By default it will list the files in the current working directory. Operation buttons allowing the user to create a directory, delete files, and rename files will also be present by default.
GTK2.Vbox get_action_area()
The action area
GTK2.HbuttonBox get_button_area()
The button area
GTK2.Button get_cancel_button()
The cancel button
string get_filename()
Return the filename.
GTK2.Button get_fileop_c_dir()
The create directory button in the file operation button group
GTK2.Button get_fileop_del_file()
The delete file button in the file operation button group
GTK2.Dialog get_fileop_dialog()
Dialog box for GTK2.FileSelection
GTK2.Button get_fileop_ren_file()
The rename file button in the file operation button group
GTK2.Button get_help_button()
The help button
GTK2.Vbox get_main_vbox()
The main vbox
GTK2.Button get_ok_button()
The ok button
int get_select_multiple()
Gets whether the user is allowed to select multiple files.
array get_selection()
Retrieves the list of selections the user has made.
GTK2.FileSelection hide_fileop_buttons()
Hides the file operation buttons that normally appear at the top of the dialog. Useful if you wish to create a custom file selector, based on GTK2.FileSelection.
GTK2.FileSelection set_filename(string fname)
Sets a default path for the file requestor. If filename includes a directory path, then the requestor will open with that path as its current working directory.
GTK2.FileSelection set_select_multiple(int select_multiple)
Sets whether the user is allowed to select multiple files.
GTK2.FileSelection show_fileop_buttons()
Shows the file operation buttons, if they have previously been hidden. The rest of the widgets in the dialog will be resized accordingly.
| CLASS GTK2.Gdk_Atom |
An X-atom. You most likely want to use GDK2.Atom.atom_name instead of GDK2._Atom(name).
GDK2._Atom GTK2.Gdk_Atom(string atom_name, int|void only_if_exists)
Create a new low-level atom. You should normally not call this function directly. Use GDK2.Atom[name] instead of GDK2._Atom(name,0).
string get_name()
Returns the name of the atom.
| CLASS GTK2.GdkColormap |
A colormap is an object that contains the mapping between the color values stored in memory and the RGB values that are used to display color values. In general, colormaps only contain significant information for pseudo-color visuals, but even for other visual types, a colormap object is required in some circumstances.
int alloc_color(GTK2.GdkColor color, int writeable, int best_match)
Alocates a single color from a colormap.
int alloc_colors(array colors, int writeable, int best_match)
Allocates colors from a colormap.
GDK2.Colormap GTK2.GdkColormap(GTK2.GdkVisual visual, int|void allocate, int|void system)
Creates a new colormap.
GDK2.Colormap free_colors(array colors)
Free colors.
GTK2.GdkScreen get_screen()
Returns the screen.
GTK2.GdkVisual get_visual()
Returns the visual.
GTK2.GdkColor query_color(int pixel)
Locates the RGB color corresponding to the given hardware pixel. pixel must be a valid pixel in the colormap; it's a programmer error to call this function with a pixel which is not in the colormap. Hardware pixels are normally obtained from alloc_colors(), or from a GDK2.Image.
| CLASS GTK2.Clipboard |
Clipboard implementation.
inherit G.Object : Object
GTK2.Clipboard clear()
Clears the contents of the clipboard.
GTK2.Clipboard get(GDK2.Atom selection)
Returns the clipboard object for the given selection.
GTK2.GdkDisplay get_display()
Gets the GDK2.Display associated with this clipboard.
GTK2.Clipboard get_for_display(GTK2.GdkDisplay display, GDK2.Atom selection)
Returns the clipboard object for the given selection.
GTK2.Clipboard set_image(GTK2.GdkPixbuf pixbuf)
Sets the contents of the clipboard to the given GDK2(Pixbuf).
GTK2.Clipboard set_text(string text, int len)
Sets the contents of the clipboard to the given UTF-8 string.
GTK2.GdkPixbuf wait_for_image()
Requests the contents of the clipboard as image and converts the result to a GDK2.Pixbuf.
string wait_for_text()
Requests the contents of the clipboard as text and converts the result to UTF-8 if necessary.
int wait_is_image_available()
Test to see if tehre is an image available to be pasted.
int wait_is_text_available()
Test to see if there is text available to be pasted. This is done by requesting the TARGETS atom and checking if it contains any of the supported text targets.
| CLASS GTK2.Socket |
Together with W(Plug), GTK2.Socket provides the ability to embed widgets from one process into another process in a fashion that is transparent to the user. One process creates a GTK2.Socket widget and, passes the XID of that widget's window to the other process, which then creates a W(Plug) window with that XID. Any widgets contained in the W(Plug) then will appear inside the first applications window.
Note that if you pass the XID of the socket to another process that will create a plug in the socket, you must make sure that the socket widget is not destroyed until that plug is created. Violating this rule will cause unpredictable consequences, the most likely consequence being that the plug will appear as a separate toplevel window.
A socket can also be used to swallow arbitrary pre-existing top-level windows using steal(), though the integration when this is done will not be as close as between a W(Plug) and a GTK2.Socket.
Signals: plug_added
plug_removed
inherit GTK2.Container : Container
GTK2.Socket add_id(int wid)
Adds an XEMBED client, such as a W(Plug), to the W(Socket).
GTK2.Socket GTK2.Socket(mapping|void props)
Create a new GTK2.Socket.
int get_id()
Gets the window id of a W(Socket) widget, which can then be used to create a client embedded inside the socket, for instance with GTK2.Plug->create().
int id()
Returns the window id, to be sent to the application providing the plug. You must realize this widget before calling this function.
| CLASS GTK2.GdkDisplay |
GdkDisplay object.
Signals: closed
inherit G.Object : Object
GDK2.Display beep()
Emits a short beep on display
GDK2.Display close()
Closes the connection to the window system for the given display, and cleans up associated resources.
GDK2.Display GTK2.GdkDisplay()
Get the default display.
GDK2.Display flush()
Flushes any requests queued for the windowing system; this happens automatically when the main loop blocks waiting for new events, but if your application is drawing without returning control to the main loop, you may need to call this function explicitly. A common case where this function needs to be called is when an application is executing drawing commands from a thread other than the thread where the main loop is running.
int get_default_cursor_size()
Returns the default size to use for cursors.
GTK2.GdkWindow get_default_group()
Returns the default group leader window for all toplevel windows. This window is implicitly create by GDK.
GTK2.GdkScreen get_default_screen()
Get the default screen.
GTK2.GdkEvent get_event()
Gets the next GDK2.Event to be processed, fetching events from the windowing system if necessary.
mapping get_maximal_cursor_size()
Returns the maximal size to use for cursors.
int get_n_screens()
Gets the number of screens managed by the display.
string get_name()
Gets the name of the display.
mapping get_pointer()
Gets the current location of the pointer and the current modifier mask.
GTK2.GdkScreen get_screen(int screen_num)
Returns a screen for one of the screens.
mapping get_window_at_pointer()
Obtains the window underneath the mouse pointer, and the x,y location. Returns 0 if the window is not known to GDK (for example, belongs to another application).
GDK2.Display keyboard_ungrab()
Release any keyboard grab.
GDK2.Display open(string name)
Opens a display.
GTK2.GdkEvent peek_event()
Gets a copy of the first GDK2.Event in the event queue, without removing the event from the queue. (Note that this function will not get more events from the windowing system. It only checks the events that have already been moved to the GDK event queue.)
int pointer_is_grabbed()
Test if the pointer is grabbed.
GDK2.Display pointer_ungrab()
Release any pointer grab.
GDK2.Display put_event(GTK2.GdkEvent event)
Appends a copy of the given event onto the front of the event queue.
int request_selection_notification(GDK2.Atom selection)
Request GdkEventOwnerChange events for ownership changes of the selection named by the given atom.
GDK2.Display set_double_click_distance(int distance)
Sets the double click distance (two clicks within this distance count as a double click and result in a GDK_2BUTTON_PRESS event). See also set_double_click_time().
GDK2.Display set_double_click_time(int msec)
Sets the double click time (two clicks within this time interval counts as a double click and result in a GDK_2BUTTON_PRESS event). Applications should not set this, it is a global user-configured setting.
GDK2.Display store_clipboard(GTK2.GdkWindow clipboard_window, array targets)
Issues a request to the clipboard manager to store the clipboard data.
int supports_clipboard_persistence()
Returns whether the specified display supports clipboard persistence, i.e. if it's possible to store the clipboard data after an application has quit. On X11 this checks if a clipboard daemon is running.
int supports_cursor_alpha()
Returns true if cursors can use an 8bit alpha channel. Otherwise, cursors are restricted to bilevel alpha (i.e. a mask).
int supports_cursor_color()
Returns true if multicolored cursors are supported. Otherwise, cursors have only a foreground and a background color.
int supports_selection_notification()
Returns whether GdkEventOwnerChange events will be sent when the owner of a selection changes.
GDK2.Display sync()
Flushes any requests queued for the windowing system and waits until all requests have been handled. This is often used for making sure that the display is synchronized with the current state of the program. Calling sync() before (gdk_error_trap_pop()) makes sure that any errors generated from earlier requests are handled before the error trap is removed.
This is most useful for X11. On windowing systems where requests are handled synchronously, this function will do nothing.
GDK2.Display warp_pointer(GTK2.GdkScreen screen, int x, int y)
Warps the pointer to the point x,y on the screen, unless the pointer is confined to a window by a grab, in which case it will be moved as far as allowed by the grab. Warping the pointer creates events as if the user had moved the mouse instantaneously to the destination.
| CLASS GTK2.CheckButton |
Check buttons inherent many properties and functions from the the
toggle buttons, but look a little different. Rather than
being buttons with text inside them, they are small squares with
the text to the right of them. These are often used for toggling
options on and off in applications.
GTK2.CheckButton( "title" )
![]()
Style properties: int indicator-size int indicator-spacing
inherit GTK2.ToggleButton : ToggleButton
GTK2.CheckButton GTK2.CheckButton(string|mapping label_or_props, int|void mnemonic)
The argument, if specified, is the label of the item. If no label is specified, use object->add() to add some other widget (such as an pixmap or image widget)
| CLASS GTK2.Pango.LayoutLine |
PangoLayoutLine.
array get_extents()
Computes the logical and ink extents of a layout line.
array get_pixel_extents()
Computes the logical and ink extents of a layout line, in device units.
int index_to_x(int index, int trailing)
Converts an index within a line to an x position.
mapping x_to_index(int x_pos)
Converts from x offset to the byte index of the corresponding character within the text of the layout. If x_pos is outside the line, index and trailing will point to the very first or very last position in the line. This determination is based on the resolved direction of the paragraph; for example, if the resolved direction is right-to-left, then an X position to the right of the line (after it) results in 0 being stored in index and trailing. An X position to the left of the line results in index pointing to the (logical) last grapheme in the line and trailing set to the number of characters in that grapheme. The reverse is true for a left-to-right line.
| CLASS GTK2.FileChooser |
Properties: int action GTK2.Widget extra-widget string file-system-backend GTK2.FileFilter filter int local-only GTk.Widget preview-widget int preview-widget-active int select-multiple int show-hidden int use-preview-label
Signals: current_folder_changed
file_activated
selection_changed
update_preview
GTK2.FileChooser add_filter(GTK2.FileFilter filter)
Adds filter to the list of filters that the user can select between. When a filter is selected, only files that are passed by that filter are displayed.
int add_shortcut_folder(string folder)
Adds a folder to be displayed with the shortcut folders in a file chooser. Note that shortcut folders do not get saved, as they are provided by the application. For example, you can use this to add a "/usr/share/mydrawprogram/Clipart" folder to the volume list.
int add_shortcut_folder_uri(string uri)
Adds a folder URI to be displayed with the shortcut folders.
int get_action()
Get the type of action the file chooser is performing.
string get_current_folder()
Gets the current folder as a local filename.
string get_current_folder_uri()
Gets the current folder as a URI.
int get_do_overwrite_confirmation()
Queries whether a file chooser is set to confirm for overwriting when the user types a file name that already exists.
GTK2.Widget get_extra_widget()
Gets the extra widget.
string get_filename()
Gets the filename for the currently select file.
array get_filenames()
Get a list of all selected file and subfolders. The returned names are full absolute paths. If files in the current folder cannot be represented as local filenames, they will be ignored. If you want those files, You may want to use get_uris() instead.
GTK2.FileFilter get_filter()
Gets the current filter.
int get_local_only()
Gets whether only local files can be selected in the file selector.
string get_preview_filename()
Gets the filename that should be previewed in a custom preview widget.
string get_preview_uri()
Gets the URI that should be previewed in a custom preview widget.
GTK2.Widget get_preview_widget()
Gets the current preview widget.
int get_preview_widget_active()
Gets whether the preview widget set by set_preview_widget_active() should be shown for the current filename.
int get_select_multiple()
Gets whether multiple files can be selected.
int get_show_hidden()
Gets whether hidden files and folders are displayed.
string get_uri()
Gets the URI for the currently selected file.
array get_uris()
List all the selected files and subfolders in the current folder. The returned names are full absolute URIs.
int get_use_preview_label()
Gets whether a stock label should be drawn with the name of the previewed file.
array list_filters()
Lists the current set of user-selectable filters.
array list_shortcut_folder_uris()
Queries the list of shortcut folders.
array list_shortcut_folders()
Queries the list of shortcut folders.
GTK2.FileChooser remove_filter(GTK2.FileFilter filter)
Removes filter from the list of filters that the user can select between.
GTK2.FileChooser remove_shortcut_folder(string folder)
Removes a folder from the list of shortcut folders.
GTK2.FileChooser remove_shortcut_folder_uri(string uri)
Removes a folder URI.
GTK2.FileChooser select_all()
Select all files.
int select_filename(string filename)
Selects a filename.
int select_uri(string uri)
Selects the file by uri.
GTK2.FileChooser set_action(int action)
Sets type of action, from opening or saving a file, or opening or saving a folder. Options are: FILE_CHOOSER_ACTION_OPEN FILE_CHOOSER_ACTION_SAVE FILE_CHOOSER_ACTION_SELECT_FOLDER FILE_CHOOSER_ACTION_CREATE_FOLDER
int set_current_folder(string folder)
Sets the current folder from a local filename. The user will be shown the full contents of the current folder, plus user interface elements for navigating to other folders.
int set_current_folder_uri(string uri)
Sets the current folder from a URI.
GTK2.FileChooser set_current_name(string filename)
Sets current name.
GTK2.FileChooser set_do_overwrite_confirmation(int setting)
Sets whether a file chooser in GTK2.FILE_CHOOSER_ACTION_SAVE mode will present a confirmation dialog if the users types a file name that already exists. This is FALSE by default.
Regardless of this setting, the chooser will emit the "confirm-overwrite" signal when appropriate.
If all you need is the stock confirmation dialog, set this property to TRUE. You can override the way confirmation is done by actually handling the "confirm-overwrite" signal.
GTK2.FileChooser set_extra_widget(GTK2.Widget widget)
Sets an application-supplied widget to provide extra options to the user.
int set_filename(string filename)
Sets filename as the current filename. Same as unselect_all() followed by select_filename();
GTK2.FileChooser set_filter(GTK2.FileFilter filter)
Sets the current filter; only the files that pass the filter will be displayed. If the user-selectable list of filters is non-empty, then the filter should be one of the filters in that list. Setting the current filter when the list of filters is empty is useful if you want to restrict the displayed set of files without letting the user change it.
GTK2.FileChooser set_local_only(int local_only)
Sets whether on local files can be selected.
GTK2.FileChooser set_preview_widget(GTK2.Widget widget)
Sets an application-supplied widget to use to display a custom preview of the currently selected file. To implement a preview, after setting the preview widget, you connect to the "update-preview" signal, and call get_preview_filename() or get_preview_uri() on each change. If you can display a preview of the new file, update your widget and set the preview active using set_preview_widget_active(). Otherwise, set the preview inactive.
When there is no application-supplied preview widget, or the application- supplied preview widget is not active, the file chooser may display an internally generated preview of the current file or it may display no preview at all.
GTK2.FileChooser set_preview_widget_active(int setting)
Sets whether the preview widget set by set_preview_widget() should be shown for the current filename. When setting is set to false, the file chooser may display an internally generated preview of the current file or it may display no preview at all.
GTK2.FileChooser set_select_multiple(int select_multiple)
Sets whether multiple files can be selected in the file selector. This is only relevant if the action is set to be FILE_CHOOSER_ACTION_OPEN or FILE_CHOOSER_ACTION_SAVE
GTK2.FileChooser set_show_hidden(int setting)
Sets whether hidden files and folders are displayed.
int set_uri(string uri)
Sets the uri as the current file.
GTK2.FileChooser set_use_preview_label(int setting)
Sets whether the file chooser should display a stock label with the name of the file that is being previewed; the default is true. Applications that want to draw the whole preview area themselves should set this to false and display the name themselves in their preview widget.
GTK2.FileChooser unselect_all()
Unselect all files.
GTK2.FileChooser unselect_filename(string filename)
Unselects a currently selected filename.
GTK2.FileChooser unselect_uri(string uri)
Unselect the uri.
| CLASS GTK2.Gnome2CanvasRect |
inherit Gnome2.CanvasRE : CanvasRE
| CLASS GTK2.Adjustment |
The GTK2.Adjustment object represents a value which has an associated lower and upper bound, together with step and page increments, and a page size. It is used within several GTK2+ widgets, including GtkSpinButton, GtkViewport, and GtkRange (which is a base class for GtkHScrollbar, GtkVScrollbar, GtkHScale, and GtkVScale).
The GtkAdjustment object does not update the value itself. Instead it is left up to the owner of the GtkAdjustment to control the value.
The owner of the GtkAdjustment typically calls the value_changed() and changed() functions after changing the value or its bounds. This results in the emission of the "value_changed" or "changed" signal respectively.
Properties: float lower float page-increment float page-size float step-increment float upper float value
Signals: changed The adjustment changed in some way
value_changed The value changed
inherit GTK2.Data : Data
GTK2.Adjustment changed()
Emites a "changed" signal.
GTK2.Adjustment clamp_page(float lower, float upper)
Updates the W(Adjustment) value to ensure that the range between lower and upper is in the current page (i.e. between value and value+page_size). If the range is larger than the page size, then only the start of it will be in the current page. A "changed" signal will be emitted if the value is changed.
GTK2.Adjustment GTK2.Adjustment(float|mapping value_or_props, float|void lower, float|void upper, float|void step_increment, float|void page_increment, float|void page_size)
The value argument is the initial value you want to give to the adjustment, usually corresponding to the topmost or leftmost position of an adjustable widget. The lower argument specifies the lowest value which the adjustment can hold. The step_increment argument specifies the "smaller" of the two increments by which the user can change the value, while the page_increment is the "larger" one. The page_size argument usually corresponds somehow to the visible area of a panning widget. The upper argument is used to represent the bottom most or right most coordinate in a panning widget's child. Therefore it is not always the largest number that value can take, since the page_size of such widgets is usually non-zero.
All values are optional, they default to 0.0. For most widgets the unit is pixels.
float get_value()
Gets the current value.
GTK2.Adjustment set_value(float to)
Sets the value. The value is clamped to lie between lower and upper.
Note that for adjustments which are used in a W(Scrollbar), the effective range of allowed values goes from lower to upper-page_size.
GTK2.Adjustment value_changed()
Emits a "value-changed" signal.
| CLASS GTK2.Scrollbar |
These are your standard, run-of-the-mill scrollbars. These should be used only for scrolling some other widget, such as a list, a text box, or a viewport (and it's generally easier to use the scrolled window widget in most cases). For other purposes, you should use scale widgets, as they are friendlier and more featureful. Style properties: int fixed-slider-length int has-backward-stepper int has-forward-stepper int has-secondary-backward-stepper int has-secondary-forward-stepper int min-slider-length
inherit GTK2.Range : Range
| CLASS GTK2.Gnome2CanvasLine |
Properties: float arrow-shape-a float arrow-shape-b float arrow-shape-c int cap-style string fill-color GDK2.Color fill-color-gdk int fill-color-rgba GDK2.Drawable fill-stipple int first-arrowhead int join-style int last-arrowhead int line-style Gnome2.CanvasPoints points int smooth int spline-steps int width-pixels float width-units
inherit Gnome2.CanvasItem : CanvasItem
| CLASS GTK2.TextTagTable |
Table of text tags.
Signals: tag_added
tag_changed
tag_removed
inherit G.Object : Object
GTK2.TextTagTable add(GTK2.TextTag tag)
Add a tag to the table. The tag is assigned the highest priority in the table.
GTK2.TextTagTable GTK2.TextTagTable()
Creates a new W(TextTagTable).
int get_size()
Returns the size of the table (number of tags).
GTK2.TextTag lookup(string name)
Look up a named tag.
GTK2.TextTagTable remove(GTK2.TextTag tag)
Remove a tag from the table.
| CLASS GTK2.ColorButton |
Properties: int alpha GDK2.Color color string title int use-alpha
Signals: color_set When a user selects a color.
inherit GTK2.Button : Button
GTK2.ColorButton GTK2.ColorButton(GTK2.GdkColor red_or_props, int|void green, int|void blue)
Create a new W(ColorButton).
int get_alpha()
Get the current alpha value.
GTK2.GdkColor get_color()
Returns the current color.
string get_title()
Get the title.
int get_use_alpha()
Gets whether the color button uses the alpha channel.
GTK2.ColorButton set_alpha(int alpha)
Sets the current opacity to alpha.
GTK2.ColorButton set_color(int|GdkColor red, int|void green, int|void blue)
Sets the current color.
GTK2.ColorButton set_title(string title)
Sets the title for the color selection dialog.
GTK2.ColorButton set_use_alpha(int use_alpha)
Sets whether or not the color button should use the alpha channel.
| CLASS GTK2.TextAttributes |
Holds text attributes.
GTK2.TextAttributes copy()
Copies src and returns it.
GTK2.TextAttributes copy_values(GTK2.TextAttributes dest)
Copies src onto dest
GTK2.TextAttributes GTK2.TextAttributes()
Create a W(TextAttributes) widget.
| CLASS GTK2.GdkImage |
A gdk (low level) image. Mainly used for W(Image) objects.
NOIMG
inherit G.Object : Object
GDK2.Image GTK2.GdkImage(int|void fast_mode, Image.Image|void image)
Create a new GDK2.Image object. The first argument is either 0, which indicates that you want a 'slow' image. If you use '1', you indicate that you want a 'fast' image. Fast images are stored in shared memory, and thus are not sent over any network. But please limit your usage of fast images, they use up a possibly limited system resource set. See the man page for shmget(2) for more information on the limits on shared segments on your system.
A 'fast' image will automatically revert back to 'slow' mode if no shared memory is available.
If the second argument is specified, it is the actual image data.
int get_pixel(int x, int y)
Get the pixel value of a pixel as a X-pixel value. It is usualy not very easy to convert this value to a rgb triple. See get_pnm.
string get_pnm()
Returns the data in the image as a pnm object. Currently, this is always a P6 (true color raw) image. This could change in the future. To get a pike image object do 'Image.PNM.decode( gdkimage->get_pnm() )'
GDK2.Image grab(GTK2.Widget widget, int xoffset, int yoffset, int width, int height)
Call this function to grab a portion of a widget (argument 1) to the image. Grabbing non-toplevel widgets may produce unexpected results. To get the size of a widget use ->xsize() and ->ysize(). To get the offset of the upper left corner of the widget, relative to it's X-window (this is what you want for the offset arguments), use ->xoffset() and ->yoffset().
GDK2.Image set(Image.Image|int image_or_xsize, int|void ysize)
Call this to set this image to either the contents of a pike image or a blank image of a specified size.
GDK2.Image set_pixel(int x, int y, int pixel)
Set the pixel value of a pixel. Please note that the pixel argument is a X-pixel value, which is not easily gotten from a RGB color. See get_pixel and set.
| CLASS GTK2.Pango.AttrList |
A PangoAttrList.
GTK2.Pango.AttrList copy()
Copy the list.
Pango.AttrList GTK2.Pango.AttrList()
Create a new empty attribute list.
| CLASS GTK2.EventBox |
Some gtk widgets don't have associated X windows, so they just draw on their parents. Because of this, they cannot receive events and if they are incorrectly sized, they don't clip so you can get messy overwritting etc. If you require more from these widgets, the EventBox is for you.
At first glance, the EventBox widget might appear to be totally useless. It draws nothing on the screen and responds to no events. However, it does serve a function - it provides an X window for its child widget. This is important as many GTK2 widgets do not have an associated X window. Not having an X window saves memory and improves performance, but also has some drawbacks. A widget without an X window cannot receive events, and does not perform any clipping on it's contents. Although the name EventBox emphasizes the event-handling function, the widget can also be used for clipping.
The primary use for this widget is when you want to receive events for a widget without a window. Examples of such widgets are labels and images.
GTK2.EventBox()->set_size_request(100,100)

Properties: int above-child int visible-window
inherit GTK2.Bin : Bin
GTK2.EventBox GTK2.EventBox(mapping|void props)
Create a new event box widget
int get_above_child()
Returns whether the event box window is above or below the windows of its child.
int get_visible_window()
Returns whether the event box has a visible window.
GTK2.EventBox set_above_child(int above_child)
Sets whether the event box window is positioned above the windows of its child, as opposed to below it. If the window is above, all events inside the event box will go to the event box. If the window is below, events in windows of child widgets will first go to that widget, and then to its parents.
The default is to keep the window below the child.
GTK2.EventBox set_visible_window(int visible_window)
Sets whether the event box uses a visible or invisible child window. The default is to use visible windows.
| CLASS GTK2.Separator |
A generic separator. Basicaly a line, like <hr> in HTML.
inherit GTK2.Widget : Widget
| CLASS GTK2.Gnome2CanvasPixbuf |
Properties: int anchor float height int height-in-pixels int height-set GDK2.Pixbuf pixbuf float width int width-in-pixels int width-set float x int x-in-pixels float y int y-in-pixels
inherit Gnome2.CanvasItem : CanvasItem
| CLASS GTK2.ComboBoxEntry |
Properties: int text-column
inherit GTK2.ComboBox : ComboBox
inherit GTK2.CellLayout : CellLayout
inherit GTK2.CellEditable : CellEditable
GTK2.ComboBoxEntry GTK2.ComboBoxEntry(string|TreeModel|mapping model, int|void text_column)
Create a new ComboBoxEntry, either empty or with a model.
GTK2.Widget entry()
Returns the GTK2.Entry widget
int get_text_column()
Returns the column which this widget is using to get the strings from.
GTK2.ComboBoxEntry set_text_column(int text_column)
Sets the model column which this widget should use to get strings from.
| CLASS GTK2.Gnome2IconSelection |
inherit GTK2.Vbox : Vbox
Gnome2.IconSelection add_defaults()
Adds the default pixmap directory into the selection widget.
Gnome2.IconSelection add_directory(string dir)
Adds the icons from the directory dir to the selection widget.
Gnome2.IconSelection clear(int|void not_shown)
Clear the currently shown icons, the ones that weren't shown yet are not cleared unless the not_shown parameter is given, in which case even those are cleared.
Gnome2.IconSelection GTK2.Gnome2IconSelection()
Creates a new icon selection widget, it uses a W(GnomeIconList) for the listing of icons
GTK2.Widget get_box()
Gets the W(Vbox) widget.
string get_icon(int full_path)
Gets the currently selected icon name, if full_path is true, it returns the full path to the icon, if none is selected it returns 0.
Gnome2.IconSelection select_icon(string filename)
Selects the icon filename. This icon must have already been added and shown
Gnome2.IconSelection show_icons()
Shows the icons inside the widget that were added with add_defaults and add_directory. Before this function isf called the icons aren't actually added to the listing and can't be picked by the user.
Gnome2.IconSelection stop_loading()
Stop the loading of images when we are in the loop in show_icons.
| CLASS GTK2.Gnome2CanvasText |
Properties: int anchor Pango.AttrList attributes int clip float clip-height float clip-width string family int family-set string fill-color GDK2.Color fill-color-gdk int fill-color-rgba GDK2.Drawable fill-stipple string font Pango.FontDescription font-dest int justification string markup int rise int rise-set float scale int scale-set int size float size-points int size-set Pango.Stretch stretch int stretch-set int strikethrough int strikethrough-set Pango.Style style int style-set string text float text-height float text-width Pango.Underline underline int underline-set Pango.Variant variant int variant-set int weight float x float x-offset float y float y-offset
inherit Gnome2.CanvasItem : CanvasItem
| CLASS GTK2.Gnome2Client |
inherit GTK2.Object : Object
Gnome2.Client GTK2.Gnome2Client()
Gets the master session management client.
Gnome2.Client disconnect()
Disconnect the client from the session manager.
Gnome2.Client flush()
This will force the underlying connection to the session manager to be flushed. This is useful if you have some pending changes that you want to make sure get committed.
string get_config_prefix()
Get the config prefix. This config prefix provides a suitable place to store any details about the state of the client which can not be described using the app's command line arguments (as set in the restart command).
string get_desktop_id()
Get the client ID of the desktop's current instance, i.e. if you consider the desktop as a whole as a session managed app, this returns its session ID using a gnome extension to session management. May return empty for apps not running under a recent version of gnome-session; apps should handle that case.
int get_flags()
Determine the client's status with the session manager.
string get_global_config_prefix()
Get the config prefix that will be returned by get_config_prefix() for clients which have NOT been restarted or cloned (i.e. for clients started by the user without '--sm-' options). This config prefix may be used to write the user's preferred config for these "new"clients".
You could also use this prefix as a place to store and retrieve config details that you wish to apply to ALL instances of the app. However, this practice limits the users freedom to configure each instance in a different way so it should be used with caution.
string get_id()
Returns the session management ID.
string get_previous_id()
Get the session management ID from the previous session.
Gnome2.Client request_phase_2()
Request the session manager to emit the "save-yourself" signal for a second time after all the clients in the session have ceased interacting with the user and entered an idle state. This might be useful if your app managers other apps and requires that they are in an idle state before saving its final data.
Gnome2.Client request_save(int save_style, int shutdown, int interact_style, int fast, int global)
Request the session manager to save the session in some way. The arguments correspond with the arguments passed to the "save-yourself" signal handler.
The save_style (GNOME_SAVE_BOTH , GNOME_SAVE_GLOBAL and GNOME_SAVE_LOCAL ) indicates whether the save should affect data accessible to other users (GTK2.GNOME_SAVE_GLOBAL) or only the state visible to the current user (GTK2.GNOME_SAVE_LOCAL), or both. Setting shutdown to true will initiate a logout. The interact_style (GNOME_INTERACT_ANY , GNOME_INTERACT_ERRORS and GNOME_INTERACT_NONE ) specifies which kinds of interaction will be available. Setting fast to true will limit the save to setting the session manager properties plus any essential data. Setting the value of global to true will request that all the other apps in the session do a save as well. A global save is mandatory when doing a shutdown.
Gnome2.Client save_any_dialog(GTK2.Dialog dialog)
May be called during a "save-yourself" handler to request that a (modal) dialog is presented to the user. The session manager decides when the dialog is shown, but it will not be shown it unless the session manager is sending an interaction style of GTK2.GNOME_INTERACT_ANY. "Cancel" and "Log out" buttons will be added during a shutdown.
Gnome2.Client save_error_dialog(GTK2.Dialog dialog)
May be called during a "save-yourself" handler when an error has occurred during the save.
Gnome2.Client set_clone_command(array argv)
Set a command the session manager can use to create a new instance of the application. Not implemented yet.
Gnome2.Client set_current_directory(string dir)
Set the directory to be in when running shutdown, discard, restart, etc. commands.
Gnome2.Client set_discard_command(array argv)
Provides a command to run when a client is removed from the session. It might delete session-specific config files, for example. Executing the discard command on the local host should delete the information saved as part of the session save that was in progress when the discard command was set. For example: string prefix=client->get_config_prefix(); array argv=({ "rm","-r" }); argv+=({ Gnome2.Config->get_real_path(prefix) }); client->set_discard_command(argv); Not implemented yet.
Gnome2.Client set_environment(string name, string value)
Set an environment variable to be placed in the client's environment prior to running restart, shutdown, discard, etc. commands.
Gnome2.Client set_global_config_prefix(string prefix)
Set the value used for the global config prefix. The global config prefix defaults to a name based on the name of the executable. This function allows you to set it to a different value. It should be called BEFORE retrieving the config prefix for the first time. Later calls will be ignored.
Gnome2.Client set_priority(int priority)
The gnome-session manager restarts clients in order of their priorities in a similar way to the start up ordering in SysV. This function allows the app to suggest a position in this ordering. The value should be between 0 and 99. A default value of 50 is assigned to apps that do not provide a value. The user may assign a different priority.
Gnome2.Client set_resign_command(array argv)
Some clients can be "undone", removing their effects and deleting any saved state. For example, xmodmap could register a resign command to undo the keymap changes it saved.
Used by clients that use the GTK2.GNOME_RESTART_ANYWAY restart style to undo their effects (these clients usually perform initialization functions and leave effects behind after they die). The resign command combines the effects of a shutdown command and a discard command. It is executed when the user decides that the client should cease to be restarted. Not implemented yet.
Gnome2.Client set_restart_command(array argv)
When clients crash or the user logs out and back in, they are restarted. This command should perform the restart. Executing the restart command on the local host should reproduce the state of the client at the time of the session save as closely as possible. Saving config info under the get_config_prefix() is generally useful. Not implemented yet.
Gnome2.Client set_restart_style(int style)
Tells the session manager how the client should be restarted in future sessions. One of GNOME_RESTART_ANYWAY , GNOME_RESTART_IF_RUNNING , GNOME_RESTART_IMMEDIATELY and GNOME_RESTART_NEVER
Gnome2.Client set_shutdown_command(array argv)
GTK2.GNOME_RESTART_ANYWAY clients can set this command to run when the user logs out but the client is no longer running.
Used by clients that use the GTK2.GNOME_RESTART_ANYWAY restart style to undo their effects (these clients usually perform initialization functions and leave effects behind after they die). The shutdown command simply undoes the effects of the client. It is executed during a normal logout. Not implemented yet.
| CLASS GTK2.SeparatorMenuItem |
A separator menu item.
inherit GTK2.MenuItem : MenuItem
GTK2.SeparatorMenuItem GTK2.SeparatorMenuItem(mapping|void props)
Create a new GTK2.SeparatorMenuItem.
| CLASS GTK2.ButtonBox |
More or less equivalent to a normal box, but you can set a few layout schemes that are not available for normal boxes. See the hbox and vbox documentation for examples. Properties: int layout-style
Child properties: int secondary
Style properties: int child-internal-pad-x int child-internal-pad-y int child-min-height int child-min-width
inherit GTK2.Box : Box
int get_child_secondary(GTK2.Widget child)
Returns whether child should appear in a secondary group of children.
int get_layout()
Returns the currently configured layout. One of BUTTONBOX_DEFAULT_STYLE , BUTTONBOX_EDGE , BUTTONBOX_END , BUTTONBOX_SPREAD and BUTTONBOX_START
GTK2.ButtonBox set_child_secondary(GTK2.Widget child, int is_secondary)
Sets whether child should appear in a secondary group of children.
GTK2.ButtonBox set_layout(int layout)
layout is one of BUTTONBOX_DEFAULT_STYLE , BUTTONBOX_EDGE , BUTTONBOX_END , BUTTONBOX_SPREAD and BUTTONBOX_START
| CLASS GTK2.Pango.Context |
PangoContext.
inherit G.Object : Object
| CLASS GTK2.SourceStyleScheme |
string get_name()
Gets the name of this scheme.
mapping get_tag_style(string name)
Gets the tag associated with the given name in this style.
| CLASS GTK2.Gnome2CanvasShape |
Properties: int cap-style string dash string fill-color GDK2.Color fill-color-gdk int fill-color-rgba GDK2.Drawable fill-stipple int join-style float miterlimit string outline-color GDK2.Color outline-color-gdk int outline-color-rgba GDK2.Drawable outline-stipple int width-pixels float width-units int wind
inherit Gnome2.CanvasItem : CanvasItem
| CLASS GTK2.ToggleButton |
Toggle buttons are derived from normal buttons and are very similar, except they will always be in one of two states, alternated by a click. They may be depressed, and when you click again, they will pop back up. Click again, and they will pop back down.
GTK2.ToggleButton("Toggle button")
![]()
GTK2.ToggleButton("Toggle button")->set_active( 1 )
![]()
Properties: int active int draw-indicator int inconsistent
Signals: toggled
inherit GTK2.Button : Button
GTK2.ToggleButton GTK2.ToggleButton(string|mapping label_or_props, int|void mnemonic)
If you supply a string, a label will be created and inserted in the button. Otherwise, use ->add(widget) to create the contents of the button.
int get_active()
Returns true if button is pressed, and false if it is raised.
int get_inconsistent()
Gets the value set by set_inconsistent().
int get_mode()
Retrieves whether the button is displayed as a separator indicator and label.
GTK2.ToggleButton set_active(int activep)
If activep is true, the toggle button will be activated.
GTK2.ToggleButton set_inconsistent(int setting)
If the user has selected a range of elements (such as some text or spreadsheet cells) that are affected by a toggle button, and the current values in that range are inconsistent, you may want to display the toggle in an "in between" state. This function turns on "in between" display.
GTK2.ToggleButton set_mode(int mode)
If true, draw indicator
GTK2.ToggleButton toggled()
emulate a 'toggle' of the button. This will emit a 'toggled' signal.
| CLASS GTK2.GdkColor |
The GDK2.Color object is used to represent a color. When you call GDK2.Color(r,g,b) the color will be allocated from the X-server. The constructor can return an exception if there are no more colors to allocate. NOIMG
int blue()
Returns the blue color component.
GDK2.Color GTK2.GdkColor(object|int color_or_r, int|void g, int|void b)
r g and b are in the range 0 to 255, inclusive. If color is specified, it should be an Image.Color object, and the only argument.
GDK2.Color destroy()
Destroys the color object. Please note that this function does not free the color from the X-colormap (in case of pseudocolor) right now.
int green()
Returns the green color component.
Image.Color.Color image_color_object()
Return a Image.Color.Color instance. This gives better precision than the rgb function.
int pixel()
Returns the pixel value of the color. See GDK2.Image->set_pixel.
int red()
Returns the red color component.
array rgb()
Returns the red green and blue color components as an array.
| CLASS GTK2.Gnome2CanvasEllipse |
inherit Gnome2.CanvasRE : CanvasRE
| CLASS GTK2.Table |
The GTK2.Table allows the programmer to arrange widgets in rows and columns, making it easy to align many widgets next to each other, horizontally and vertically.
GTK2.Table(2,2,0)->attach_defaults( GTK2.Label("0,0"), 0, 1, 0, 1)->attach_defaults( GTK2.Label("0,1"), 0, 1, 1, 2)->attach_defaults( GTK2.Label("1,0"), 1, 2, 0, 1)->attach_defaults( GTK2.Label("1,1"), 1, 2, 1, 2)->set_col_spacings(10)->set_row_spacings(10)
![]()
GTK2.Table(2,2,0)->attach_defaults( GTK2.Label("0,0-1,0"), 0, 2, 0, 1)->attach_defaults( GTK2.Label("0,1"), 0, 1, 1, 2)->attach_defaults( GTK2.Label("1,1"), 1, 2, 1, 2)->set_col_spacings(10)->set_row_spacings(10)
![]()
Properties: int column-spacing int homogeneous int n-columns int n-rows int row-spacing
Child properties: int bottom-attach int left-attach int right-attach int top-attach int x-options int x-padding int y-options int y-padding
inherit GTK2.Container : Container
GTK2.Table attach(GTK2.Widget subwidget, int left, int right, int top, int bottom, int xoptions, int yoptions, int xpad, int ypad)
The left and right attach arguments specify where to place the widget, and how many boxes to use. If you want a button in the lower right table entry of our 2x2 table, and want it to fill that entry ONLY. left_attach would be = 1, right_attach = 2, top_attach = 1, bottom_attach = 2.
Now, if you wanted a widget to take up the whole top row of our 2x2 table, you'd use left_attach = 0, right_attach = 2, top_attach = 0, bottom_attach = 1.
The xoptions and yoptions are used to specify packing options and may be OR'ed together to allow multiple options.
These options are: <ul> <li> GTK2.Fill - If the table box is larger than the widget, and GTK_FILL is specified, the widget will expand to use all the room available.</li> <li> GTK2.Shrink - If the table widget was allocated less space then was requested (usually by the user resizing the window), then the widgets would normally just be pushed off the bottom of the window and disappear. If GTK_SHRINK is specified, the widgets will shrink with the table.</li> <li> GTK2.Expand - This will cause the table cell to expand to use up any remaining space in the window.</li> </ul>
Padding is just like in boxes, creating a clear area around the widget specified in pixels
GTK2.Table attach_defaults(GTK2.Widget subwidget, int left, int right, int top, int bottom)
As there are many options associated with attach(), this convenience function provides the programmer with a means to add children to a table with identical padding and expansion options.
xoptions, yoptions, xpadding and ypadding are all set the their default values. For the options that is GTK2.Fill|GTK2.Expand. For the padding it is 0.
GTK2.Table GTK2.Table(int|mapping width_or_props, int|void height, int|void homogeneousp)
Used to create a new table widget. An initial size must be given by specifying how many rows and columns the table should have, although this can be changed later with resize().
There can never be more than 65535 colums nor more than 65535 rows.
setting homogeneousp to 1 forces the all tablecells to be exactly the same size.
int get_col_spacing(int col)
Gets the amound of space between col and col+1.
int get_default_col_spacing()
Gets the default column spacing for the table.
int get_default_row_spacing()
Gets the default row spacing for the table.
int get_homogeneous()
Returns whether the table cells are all constrained to the same width and height.
int get_row_spacing(int row)
Gets the amount of space between row and row+1.
GTK2.Table resize(int rows, int columns)
If you need to change a table's size after it has been created, this function allows you to do so.
GTK2.Table set_col_spacing(int x, int spacing)
alters the amount of space between a given table column and the adjacent columns.
GTK2.Table set_col_spacings(int spacing)
Sets the space between every column in the table equal to spacing.
GTK2.Table set_homogeneous(int homogeneousp)
Set the homogeneous flag.
GTK2.Table set_row_spacing(int y, int spacing)
alters the amount of space between a given table row and the adjacent rows.
GTK2.Table set_row_spacings(int spacing)
Sets the space between every row in the table equal to spacing.
| CLASS GTK2.FileFilter |
A filter for selecting a file subset.
inherit GTK2.Data : Data
GTK2.FileFilter add_mime_type(string mime_type)
Adds a rule allowing a given mime type.
GTK2.FileFilter add_pattern(string pattern)
Adds a rule allowing a shell style glob.
GTK2.FileFilter add_pixbuf_formats()
Adds a rule allowing image files in the formats support by W(Pixbuf).
GTK2.FileFilter GTK2.FileFilter()
Creates a new W(FileFilter) with no rules added to it. Such a filter doesn't accept any files, so is not particularly useful until you add rules with add_mime_type(), add_pattern(), or add_custom(). To create a filter accepts any file, use add_pattern("*").
string get_name()
Gets the human-readable name for the filter.
GTK2.FileFilter set_name(string name)
Sets the human-readable name of the filter; this is the string that will be displayed in the file selector user interface if there is a selectable list of filters.
| CLASS GTK2.Data |
A class inherited by all objects used to store data (they are not widgets)
Signals: disconnect
inherit GTK2.Object : Object
| CLASS GTK2.Entry |
Use this widget when you want the user to input a single line of text.
GTK2.Entry()->set_text("Hello world")->set_editable(1)
![]()
Properties: int activates-default int cursor-position int editable int has-frame int invisible-char int max-length int scroll-offset int selection-bound string text int visibility int width-chars float xalign
Style properties:
Signals: activate
backspace
copy_clipboard
cut_clipboard
delete_from_cursor
insert_at_cursor
move_cursor
paste_clipboard
populate_popup
toggle_overwrite
inherit GTK2.Widget : Widget
inherit GTK2.CellEditable : CellEditable
inherit GTK2.Editable : Editable
GTK2.Entry GTK2.Entry(int|mapping maxlen_or_props)
Create a new W(Entry) widget.
int get_activates_default()
Retrieves the value set by set_activates_default().
float get_alignment()
Gets the value set by set_alignment().
GTK2.EntryCompletion get_completion()
Returns the completion object.
int get_has_frame()
Gets the value set by set_has_frame().
int get_invisible_char()
Retrieves the character displayed in place of the real characters for entries with visibility set to false.
GTK2.Pango.Layout get_layout()
Gets the Pango.Layout used to display the entry. The layout is useful to e.g. convert text positions to pixel positions, in combination with get_layout_offsets().
Keep in mind that the layout text may contain a preedit string, so layout_index_to_text_index() and text_index_to_layout_index() are needed to convert byte indices in the layout to byte indices in the entry contents.
mapping get_layout_offsets()
Obtains the position of the Pango.Layout used to render text in the entry, in widget coordinates. Useful if you want to line up the text in an entry with some other text, e.g. when using the entry to implement editable cells in a sheet widget.
Also useful to convert mouse events into coordinates inside the Pango.Layout, e.g. to take some action if some part of the entry text is clicked.
Keep in mind that the layout text may contain a preedit string, so layout_index_to_text_index() and text_index_to_layout_index() are needed to convert byte indices in the layout to byte indices in the entry contents.
int get_max_length()
Retrieves the maximum allowed length of the text.
string get_text()
Returns the contents of the entry widget.
int get_visibility()
Retrieves whether the text is visible.
int get_width_chars()
Gets the value set by set_width_chars().
int layout_index_to_text_index(int layout_index)
Converts from a position in the entry contents (returned by get_text()) to a position in the entry's Pango.Layout (returned by get_layout()), with text retrieved via Pango.Layout->get_text().
GTK2.Entry set_activates_default(int setting)
If setting is true, pressing Enter will activate the default widget for the window containing the entry. This usually means that the dialog box containing the entry will be closed, since the default widget is usually one of the dialog buttons.
GTK2.Entry set_alignment(float align)
Sets the alignment for the ocntents of the entry. This controls the horizontal positioning of the contents when the displayed text is shorter than the width of the entry.
GTK2.Entry set_completion(GTK2.EntryCompletion completion)
Sets completion to be the auxiliary completion object to use. All further configuration of the completion mechanism is done on completion using the GTK2.EntryCompletion API.
GTK2.Entry set_has_frame(int setting)
Sets whether the entry has a beveled frame around it.
GTK2.Entry set_invisible_char(int ch)
Sets the character to use in place of the actual text when set_invisibility() has been called to set text visibility to false. i.e. this is the character used in "password" mode to show the user how many characters have been type. The default invisible char is an asterisk ('*'). If you set the invisible char to 0, then the user will get no feedback at all; there will be no text on the screen as they type.
GTK2.Entry set_max_length(int maxlen)
Sets the maximum allowed length of the contents. If the current contents are longer than the given length, then they will be truncated to fit. Range is 0-65536. 0 means no maximum.
GTK2.Entry set_text(string text)
Set the text to the specified string, replacing the current contents.
GTK2.Entry set_visibility(int visiblep)
0 indicates invisible text (password boxes, as an example)
GTK2.Entry set_width_chars(int n_chars)
changes the size request of the entry to be about the right size for n_chars characters. Note that it changes the size request, the size can still be affected by how you pack the widget into containers. If n_chars is -1, the size reverts to the default entry size.
int text_index_to_layout_index(int text_index)
Opposite of layout_index_to_text_index().
| CLASS GTK2.RcStyle |
RC settings.
inherit G.Object : Object
GTK2.RcStyle copy()
Makes a copy.
GTK2.RcStyle GTK2.RcStyle()
Creates a new W(Rc).
GTK2.RcStyle set_base(array colors)
Set base.
GTK2.RcStyle set_bg(array colors)
Set bg.
GTK2.RcStyle set_bg_pixmap_name(array names)
Set bg_pixmap_name.
GTK2.RcStyle set_color_flags(array flags)
Set color_flags.
GTK2.RcStyle set_fg(array colors)
Set fg.
GTK2.RcStyle set_name(string name)
Set the name.
GTK2.RcStyle set_text(array colors)
Set text.
GTK2.RcStyle set_xthickness(int value)
Set xthickness.
GTK2.RcStyle set_ythickness(int value)
Set ythickness.
| CLASS GTK2.WindowGroup |
Limit the effect of grabs.
inherit G.Object : Object
GTK2.WindowGroup add_window(GTK2.Window window)
Add a window.
GTK2.WindowGroup GTK2.WindowGroup()
Creates a new GTK2.WindowGroup object. Grabs added with GTK2.grab_add() only affect windows with the same GTK2.WindowGroup.
GTK2.WindowGroup remove_window(GTK2.Window window)
Remove a window.
| CLASS GTK2.Style |
Style settings.
Signals: realize
unrealize
inherit G.Object : Object
GTK2.Style attach(GTK2.Widget window)
Attaches a style to a window; this process allocates the colors and creates the GC's for the style - it specializes it to a particular visual and colormap. The process may involve the creation of a new style if the style has already been attached to a window with a different style and colormap.
GTK2.Style copy()
Copy a style.
GTK2.Style GTK2.Style()
Creates a new style.
GTK2.Style detach()
Detach a style.
GTK2.IconSet lookup_icon_set(string stock_id)
Lookup the icon set.
GTK2.Style paint_arrow(GTK2.Widget window, int state, int shadow, GTK2.GdkRectangle rect, GTK2.Widget widget, string detail, int arrow, int fill, int x, int y, int width, int height)
Draws an arrow in the given rectangle on window using the given parameters. arrow determines the direction of the arrow.
GTK2.Style paint_box(GTK2.Widget window, int state, int shadow, GTK2.GdkRectangle rect, GTK2.Widget widget, string detail, int x, int y, int width, int height)
Draws a box on window with the given parameters.
GTK2.Style paint_box_gap(GTK2.Widget window, int state, int shadow, GTK2.GdkRectangle rect, GTK2.Widget widget, string detail, int x, int y, int width, int height, int gap_side, int gap_x, int gap_width)
Draws a box in window using the given style and state and shadow type, leaving a gap in one side.
GTK2.Style paint_check(GTK2.Widget window, int state, int shadow, GTK2.GdkRectangle rect, GTK2.Widget widget, string detail, int x, int y, int width, int height)
Draws a check button indicator in the given rectangle on window.
GTK2.Style paint_diamond(GTK2.Widget window, int state, int shadow, GTK2.GdkRectangle rect, GTK2.Widget widget, string detail, int x, int y, int width, int height)
Draws a diamond in the given rectangle on window.
GTK2.Style paint_expander(GTK2.Widget window, int state, GTK2.GdkRectangle rect, GTK2.Widget widget, string detail, int x, int y, int style)
Draws an expander as used in GTK2.TreeView. x and y specify the center of the expander. The size of the expander is determined by the "expander-size" style property of widget. (If widget is 0 or doesn't have an "expander-size" property, an unspecified default size will be used, since the caller doesn't have sufficient information to position the expander, this is likely not useful.) The expander is expander_size pixels tall in the collapsed position and expander_size pixels wide in the expanded position.
GTK2.Style paint_extension(GTK2.Widget window, int state, int shadow, GTK2.GdkRectangle rect, GTK2.Widget widget, string detail, int x, int y, int width, int height, int gap_side)
Draws an extension, i.e. a notebook tab.
GTK2.Style paint_flat_box(GTK2.Widget window, int state, int shadow, GTK2.GdkRectangle rect, GTK2.Widget widget, string detail, int x, int y, int width, int height)
Draws a flat box on window.
GTK2.Style paint_focus(GTK2.Widget window, int state, GTK2.GdkRectangle rect, GTK2.Widget widget, string detail, int x, int y, int width, int height)
Draws a focus indicator around the given rectangle.
GTK2.Style paint_handle(GTK2.Widget window, int state, int shadow, GTK2.GdkRectangle rect, GTK2.Widget widget, string detail, int x, int y, int width, int height, int orientation)
Draws a handle as used in GTK2.HandleBox and GTK2.Paned.
GTK2.Style paint_hline(GTK2.Widget window, int state, GTK2.GdkRectangle rect, GTK2.Widget widget, string detail, int x1, int x2, int y)
Draws a horizontal line from (x1,y) to (x2,y).
GTK2.Style paint_layout(GTK2.Widget window, int state, int use_text, GTK2.GdkRectangle rect, GTK2.Widget widget, string detail, int x, int y, GTK2.Pango.Layout layout)
Draw a pango layout. Use widget->create_pango_layout() to get a Pango.Layout.
GTK2.Style paint_option(GTK2.Widget window, int state, int shadow, GTK2.GdkRectangle rect, GTK2.Widget widget, string detail, int x, int y, int width, int height)
Draws a radio button indicator in the given rectangle.
GTK2.Style paint_resize_grip(GTK2.Widget window, int state, GTK2.GdkRectangle rect, GTK2.Widget widget, string detail, int edge, int x, int y, int width, int height)
Draws a resize grip in the given rectangle.
GTK2.Style paint_shadow(GTK2.Widget window, int state, int shadow, GTK2.GdkRectangle rect, GTK2.Widget widget, string detail, int x, int y, int width, int height)
Draws a shadow around the given rectangle.
GTK2.Style paint_shadow_gap(GTK2.Widget window, int state, int shadow, GTK2.GdkRectangle rect, GTK2.Widget widget, string detail, int x, int y, int width, int height, int gap_side, int gap_x, int gap_width)
Draws a shadow around the given rectangle in window, leaving a gap in one side.
GTK2.Style paint_slider(GTK2.Widget window, int state, int shadow, GTK2.GdkRectangle rect, GTK2.Widget widget, string detail, int x, int y, int width, int height, int orientation)
Paint a slider.
GTK2.Style paint_tab(GTK2.Widget window, int state, int shadow, GTK2.GdkRectangle rect, GTK2.Widget widget, string detail, int x, int y, int width, int height)
Draws an option menu tab (i.e. the up and down pointing arrows).
GTK2.Style paint_vline(GTK2.Widget window, int state, GTK2.GdkRectangle rect, GTK2.Widget widget, string detail, int y1, int y2, int x)
Draws a vertical line from (x,y1) to (x,y2).
GTK2.GdkPixbuf render_icon(GTK2.IconSource source, int direction, int state, int size, GTK2.Widget widget, string detail)
Renders the icon specified by source at the given size according to the given parameters and returns the result in a pixbuf.
GTK2.Style set_background(GTK2.Widget window, int state)
Sets the background of window to the background color or pixmap specified by style for the given state.
| CLASS GTK2.Settings |
Properties: int gtk-alternative-button-order int gtk-button-images int gtk-can-change-accels string gtk-color-palette int gtk-cursor-blink int gtk-cursor-blink-time string gtk-cursor-theme-name int gtk-cursor-theme-size int gtk-dnd-drag-threshold int gtk-double-click-distance int gtk-double-click-time int gtk-enable-animations int gtk-entry-select-on-focus string gtk-font-name string gtk-icon-sizes string gtk-icon-theme-name string gtk-key-theme-name string gtk-menu-bar-accel gint gtk-menu-bar-popup-delay int gtk-menu-images int gtk-menu-popdown-delay int gtk-menu-popup-delay string gtk-modules int gtk-split-cursor string gtk-theme-name int gtk-toolbar-icon-size int gtk-toolbar-style int gtk-xft-antialias int gtk-xft-dpi int gtk-xft-hinting string gtk-xft-hintstyle string gtk-xft-rgba
inherit G.Object : Object
GTK2.Settings GTK2.Settings()
Get the default GTK2.Settings object
| CLASS GTK2.TextView |
Properties: int accepts-tab GTK2.TextBuffer buffer int cursor-visible int editable int indent int justification int left-margin int overwrite int pixels-above-lines int pixels-below-lines int pixels-inside-wrap int right-margin Pango.TabArray tabs int wrap-mode
Style properties: GDK2.Color error-underline-color
Signals: backspace
copy_clipboard
cut_clipboard
delete_from_cursor
insert_at_cursor
move_cursor
move_focus
move_viewpoert
page_horizontally
paste_clipboard
populate_popup
select_all
set_anchor
set_scroll_adjustments
toggle_overwrite
inherit GTK2.Container : Container
GTK2.TextView add_child_at_anchor(GTK2.Widget child, GTK2.TextChildAnchor anchor)
Adds a child widget in the text buffer, at the given anchor.
GTK2.TextView add_child_in_window(GTK2.Widget child, int wintype, int xpos, int ypos)
Adds a child at fixed coordinates in one of the text widget's windows. The window must have nonzero size (see GTK2.TextView->set_border_window_size()). Note that the child coordinates are given relative to the GDK2.Window in question, and that these coordinates have no sane relationship to scrolling. When placing a child in GTK2.TEXT_WINDOW_WIDGET, scrolling is irrelevant, the child floats above all scrollable areas. But when placing a child in one of the scrollable windows (border windows or text window), you'll need to compute the child's correct position in buffer coordinates any time scrolling occurs or buffer changes occur, and then call GTK2.TextView->move_child() to update the child's position. Unfortunately there's no good way to detect that scrolling has occured, using the current API; a possible hack would be to update all child positions when the scroll adjustments change or the text buffer changes.
int backward_display_line(GTK2.TextIter iter)
See forward_display_line().
int backward_display_line_start(GTK2.TextIter iter)
Moves the iter backward to the next display line start.
array buffer_to_window_coords(int wintype, int buffer_x, int buffer_y)
Converts coordinate (buffer_x,buffer_y) to coordinates for the window win, and returns the results. wintype is one of TEXT_WINDOW_BOTTOM , TEXT_WINDOW_LEFT , TEXT_WINDOW_PRIVATE , TEXT_WINDOW_RIGHT , TEXT_WINDOW_TEXT , TEXT_WINDOW_TOP and TEXT_WINDOW_WIDGET .
GTK2.TextView GTK2.TextView(GTK2.TextBuffer buffer_or_props)
Create a new W(TextView).
int forward_display_line(GTK2.TextIter iter)
Moves iter forward by one display (wrapped) line. A display line is different from a paragraph. Paragraphs are separated by newlines or other paragraph separator characters. Display lines are created by line-wrapping a paragraph. If wrapping is turned off, display lines and paragraphs will be the same. Display lines are divided differently for each view, since they depend on the view's width; paragraphs are the same in all view, since they depend on the contents of the W(TextBuffer).
int forward_display_line_end(GTK2.TextIter iter)
Moves the iter forward to the next display line end.
int get_accepts_tab()
Returns whether pressing the Tab key inserts a tab character.
int get_border_window_size(int wintype)
Gets the width of the specified border window.
GTK2.TextBuffer get_buffer()
Returns the buffer displayed by this view.
int get_cursor_visible()
Find out whether the cursor is being displayed.
GTK2.TextAttributes get_default_attributes()
Obtains a copy of the default text attributes. These are the attributes used for text unless a tag overrides them.
int get_editable()
Gets the default editability.
int get_indent()
Gets the default indentation for paragraphs.
GTK2.TextIter get_iter_at_location(int x, int y)
Retrieves the iterator at buffer coordinates x and y. Buffer coordinates are coordinates for the entire buffer, not just the currently-displayed portions. If you have coordinates from an event, you have to convert those to buffer coordinates with window_to_buffer_coords().
GTK2.TextIter get_iter_at_position(int x, int y)
Retrieves the iterator pointing to the character at buffer coordinates x and y.
GTK2.GdkRectangle get_iter_location(GTK2.TextIter iter)
Gets a rectangle which roughly contains the character at iter. The rectangle position is in buffer coordinates; use buffer_to_window_coords() to convert these coordinates to coordinates for one of the windows in the text view.
int get_justification()
Gets the default justification.
int get_left_margin()
Gets the default left margin size of paragraphs.
GTK2.TextIter get_line_at_y(int y)
Returns a W(TextIter) for the start of the line containing the coordinate y. y is in buffer coordinates, convert from window coordinates with window_to_buffer_coords().
mapping get_line_yrange(GTK2.TextIter iter)
Gets the y coordinate of the top of the line containing iter, and the height of the line. The coordinate is a buffer coordinate; convert to window coordinates with buffer_to_window_coords().
int get_overwrite()
Returns whether the view is in overwrite mode or not.
int get_pixels_above_lines()
Gets the default number of pixels to put above paragraphs.
int get_pixels_below_lines()
Gets the value set by set_pixels_below_lines().
int get_pixels_inside_wrap()
Gets the value set by set_pixels_inside_wrap().
int get_right_margin()
Gets the default right margin size of paragraphs.
GTK2.Pango.TabArray get_tabs()
Gets the default tabs. Tags in the buffer may override the defaults. The return value will be 0 if "standard" (8-space) tabs are used.
GTK2.GdkRectangle get_visible_rect()
Returns a rectangle with the currently-visible region of the buffer, in buffer coordinates. Convert to window coordinates with buffer_to_window_coords().
GTK2.GdkWindow get_window(int wintype)
Retrieves the GDK2.Window corresponding to an area of the text view; possible windows include the overall widget window, child windows on the left, right, top, bottom, and the window that displays the text buffer. Windows are 0 and nonexistent if their width or height is 0, and are nonexistent before the widget has been realized.
int get_window_type(GTK2.GdkWindow window)
Usually used to find out which window an event corresponds to. If you connect to an event signal, this function should be called on event->window to see which window it was. One of TEXT_WINDOW_BOTTOM , TEXT_WINDOW_LEFT , TEXT_WINDOW_PRIVATE , TEXT_WINDOW_RIGHT , TEXT_WINDOW_TEXT , TEXT_WINDOW_TOP and TEXT_WINDOW_WIDGET .
int get_wrap_mode()
Gets the line wrapping mode.
GTK2.TextView move_child(GTK2.Widget child, int x, int y)
Updates the position of a child.
int move_mark_onscreen(GTK2.TextMark mark)
Moves a mark within the buffer so that it's located within the currently visible text-area.
int move_visually(GTK2.TextIter iter, int count)
Move the iterator a given number of characters visually, treating it as the strong cursor position. If count is positive, then the new strong cursor position will be count positions to the right of the old cursor position. If count is negative then the new strong cursor position will be count positions to the left of the old cursor position.
In the presence of bidirection text, the correspondence between logical and visual order will depend on the direction of the current run, and there may be jumps when the cursor is moved off the end of a run.
int place_cursor_onscreen()
Moves the cursor to the currently visible region of the buffer, if it isn't there already.
GTK2.TextView scroll_mark_onscreen(GTK2.TextMark mark)
Scrolls the view the minimum distance such that mark is contained within the visible area.
GTK2.TextView scroll_to_iter(GTK2.TextIter iter, float within_margin, int use_align, float xalign, float yalign)
Scrolls the view so that iter is on the screen as with scroll_to_mark().
GTK2.TextView scroll_to_mark(GTK2.TextMark mark, float within_margin, int use_align, float xalign, float yalign)
Scrolls the view so that mark is on the screen in the position indicated by xalign and yalign. An alignment of 0.0 indicates left or top, 1.0 indicates right or bottom, 0.5 means center. If use_align is false, the text scrolls the minimal distance to get the mark onscreen, possibly not scrolling at all. The effective screen for purposes of this function is reduced by the margin of size within_margin.
GTK2.TextView set_accepts_tab(int accepts_tab)
Sets the behavior of the text widget when the Tab key is pressed. If accepts_tab is true a tab character is inserted. If accepts_tab is false the keyboard focus is moved to the next widget in the focus chain.
GTK2.TextView set_border_window_size(int wintype, int size)
Sets the width of GTK2.TEXT_WINDOW_LEFT or GTK2.TEXT_WINDOW_RIGHT, or the height of GTK2.TEXT_WINDOW_TOP or GTK2.TEXT_WINDOW_BOTTOM. Automatically destroys the corresponding window if the size is set to 0, and creates the window if the size is set to non-zero. This function can only be used for the "border windows", it doesn't work with GTK2.TEXT_WINDOW_WIDGET, GTK2.TEXT_WINDOW_TEXT, or GTK2.TEXT_WINDOW_PRIVATE.
GTK2.TextView set_buffer(GTK2.TextBuffer buffer)
Sets buffer as the buffer being displayed.
GTK2.TextView set_cursor_visible(int setting)
Toggles whether the insertion point is displayed. A buffer with no editable text probably shouldn't have a visible cursor, so you may want to turn the cursor off.
GTK2.TextView set_editable(int setting)
Sets the default editability. You can override this default setting with tags in the buffer, using the "editable" attribute of tags.
GTK2.TextView set_indent(int indent)
Sets the default indentation for paragraphs. May be overridden by tags.
GTK2.TextView set_justification(int just)
Sets the default justification of text. One of JUSTIFY_CENTER , JUSTIFY_FILL , JUSTIFY_LEFT and JUSTIFY_RIGHT .
GTK2.TextView set_left_margin(int margin)
Sets the default left margin. May be overridden by tags.
GTK2.TextView set_overwrite(int overwrite)
Changes the overwrite mode, true for on, false for off.
GTK2.TextView set_pixels_above_lines(int pixels)
Sets the default number of blank pixels above paragraphs. Tags in the buffer may override the defaults.
GTK2.TextView set_pixels_below_lines(int pixels)
Sets the default number of blank pixels to put below paragraphs. May be overridden by tags applied to the buffer.
GTK2.TextView set_pixels_inside_wrap(int pixels)
Sets the default number of pixels of blank space to leave between displayed/wrapped lines within a paragraph. May be overridden by tags.
GTK2.TextView set_right_margin(int margin)
Sets the default right margin. May be overridden by tags.
GTK2.TextView set_tabs(GTK2.Pango.TabArray tabs)
Sets the default tab stops for paragraphs. Tags in the buffer may override the default.
GTK2.TextView set_wrap_mode(int wrap_mode)
Sets the line wrapping. One of WRAP_CHAR , WRAP_NONE , WRAP_WORD and WRAP_WORD_CHAR .
int starts_display_line(GTK2.TextIter iter)
Determines whether iter is at the start of a display line.
array window_to_buffer_coords(int wintype, int window_x, int window_y)
Converts coordinates on the window identified by wintype to buffer coordinates, returning the result.
| CLASS GTK2.LineCommentTag |
inherit GTK2.SourceTag : SourceTag
GTK2.LineCommentTag GTK2.LineCommentTag(string id, string name, string pattern_start)
Creates a new line comment tag object with the provided arguments.
| CLASS GTK2.GdkPixbufAnimationIter |
An iterator for a PixbufAnimation.
inherit G.Object : Object
int advance()
Possibly advance an animation to a new frame.
int get_delay_time()
Gets the number of milliseconds the current pixbuf should be displayed, or -1 if the current pixbuf should be displayed forever.
GTK2.GdkPixbuf get_pixbuf()
Gets the current pixbuf which should be displayed; the pixbuf will be the same size as the animation itself (GDK2.PixbufAnimation->get_width(), GDK2.PixbufAnimation->get_height()). This pixbuf should be displayed for get_delay_time() milliseconds.
int on_currently_loading_frame()
Used to determine how to respond to the area_updated signal on GDK2.PixbufLoader when loading an animation.
| CLASS GTK2.GladeXML |
Glade is a free GUI builder for GTK2+ and Gnome. It's normally used to create C-code, but can also produce code for other languages. Libglade is a utility library that builds the GI from the Glade XML save files. This module uses libglade and allows you to easily make GUI designs to be used with your Pike applications.
inherit G.Object : Object
GTK2.GladeXML GTK2.GladeXML(string filename_or_buffer, int|void size, string|void root, string|void domain)
Creates a new GladeXML object (and the corresponding widgets) from the XML file. Optionally it will only build the interface from the widget node root. This feature is useful if you only want to build say a toolbar or menu from the XML file, but not the window it is embedded in. Note also that the XML parse tree is cached to speed up creating another GladeXML object from the same file. The third optional argument is used to specify a different translation domain from the default to be used. If xml description is in a string buffer instead, specify the size (or -1 to auto-calculate). If size is 0, then it will assume a file with root and/or domain specified.
int get_signal_id(GTK2.Widget widget)
Used to get the signal id attached to a GladeXML object.
GTK2.Widget get_widget(string name)
This function is used to get the widget corresponding to name in the interface description. You would use this if you have to do anything to the widget after loading.
string get_widget_name(GTK2.Widget widget)
Used to get the name of a widget that was generated by a GladeXML object.
array get_widget_prefix(string name)
This function is used to get a list GTK2.Widgets with names that start with the string name in the interface description.
GTK2.GladeXML signal_autoconnect(mapping callbacks, mixed data)
Try to connect functions to all signals in the interface. The mapping should consist of handler name : function pairs. The data argument will be saved and sent as the first argument to all callback functions.
| CLASS GTK2.GdkRectangle |
Rectangle class.
mixed cast(string type)
Normally used like (mapping)rectangle or (array)rectangle.
GDK2.Rectangle GTK2.GdkRectangle(int x, int y, int width, int height)
Create a new rectangle
NOIMG
GDK2.Rectangle set(int x, int y, int width, int height)
Set the upper left corner and the size of the rectangle.
| CLASS GTK2.TreeStore |
A tree-like data structure that can be used with W(TreeView).
inherit G.Object : Object
inherit GTK2.TreeModel : TreeModel
inherit GTK2.TreeSortable : TreeSortable
inherit GTK2.TreeDragSource : TreeDragSource
inherit GTK2.TreeDragDest : TreeDragDest
GTK2.TreeIter append(GTK2.TreeIter parent)
Append a new row. If parent is valid, then it will append the new row after the last child, otherwise it will append a row to the toplevel.
GTK2.TreeStore clear()
Removes all rows.
GTK2.TreeStore GTK2.TreeStore(array types)
Create a new tree store with as many columns as there are items in the array. A type is either a string representing a type name, such as "int" or "float", or an actual widget. If it is a widget, the column in question should be a widget of the same type that you would like this column to represent.
GTK2.TreeIter insert(GTK2.TreeIter parent, int position)
Insert a row at position. If parent is valid, will create as child, otherwise at top level. If position is larger than then number of rows at that level, it will be added to the end of the list. iter will be changed to point to the new row.
GTK2.TreeIter insert_after(GTK2.TreeIter parent, GTK2.TreeIter sibling)
Insert a new row after sibling. If sibling is 0, then the row will be prepended to parent's children. If parent and sibling are both 0, then the row will be prepended to the toplevel.
GTK2.TreeIter insert_before(GTK2.TreeIter parent, GTK2.TreeIter sibling)
Insert a row before sibling. If sibling is 0, then the row will be appended to parent's children. If parent and sibling are 0, then the row will be appended to the toplevel.
int is_ancestor(GTK2.TreeIter iter, GTK2.TreeIter descendant)
Returns true if iter is an ancestor of descendant.
int iter_depth(GTK2.TreeIter iter)
Get the depth of iter. This will be 0 for anything on the root level, 1 for anything down a level, and so on.
GTK2.TreeStore move_after(GTK2.TreeIter iter, GTK2.TreeIter position)
Moves iter to after position. These should be at the same level. This only works if the store is unsorted. If position is omitted, iter will be moved to the start of the level.
GTK2.TreeStore move_before(GTK2.TreeIter iter, GTK2.TreeIter position)
Moves iter to before position. These should be at the same level. This only works if the store is unsorted. If position is omitted, iter will be moved to the end of the level.
GTK2.TreeIter prepend(GTK2.TreeIter parent)
Prepend a new row. If parent is valid, then it will prepend the new row before the first child of parent, otherwise it will prepend a new row to the toplevel.
GTK2.TreeStore remove(GTK2.TreeIter iter)
Remove iter. iter is set to the next valid row at that level, or invalidated if it was the last one.
GTK2.TreeStore set_row(GTK2.TreeIter iter, array values)
Set the data in an entire row.
GTK2.TreeStore set_value(GTK2.TreeIter iter, int column, mixed value)
Set the data in the cell specified by iter and column.
GTK2.TreeStore swap(GTK2.TreeIter a, GTK2.TreeIter b)
Swap 2 rows. Only works if this store is unsorted.
| CLASS GTK2.Alignment |
The W(Alignment) widget controls the alignment and size of its child widget. It has four settings: xscale, yscale, xalign, and yalign.
The scale settings are used to specify how much the child widget should expand to fill the space allocated to the W(Alignment). The values can range from 0 (meaning the child doesn't expand at all) to 1 (meaning the child expands to fill all of the available space).
The align settings are used to place the child widget within the available area. The values range from 0 (top or left) to 1 (bottom or right). Of course, if the scale settings are both set to 1, the alignment settings have no effect.
NOIMG Properties: int bottom-padding int left-padding int right-padding int top-padding float xalign float xscale float yalign float yscale
inherit GTK2.Bin : Bin
GTK2.Alignment GTK2.Alignment(float|mapping xalign_or_props, float|void yalign, float|void xscale, float|void yscale)
|
GTK2.Alignment set(float xalign, float yalign, float xscale, float yscale)
|
GTK2.Alignment set_padding(int padding_top, int padding_bottom, int padding_left, int padding_right)
Sets the padding on the different sides.
| CLASS GTK2.IconTheme |
Looking up icons by name.
Signals: changed
inherit G.Object : Object
GTK2.IconTheme append_search_path(string path)
Appends a directory to the search path.
GTK2.IconTheme GTK2.IconTheme()
Creates a new icon theme object. Icon theme objects are used to lookup an icon by name in a particular icon theme. Usually you'll want to use get_default() rather than creating a new icon theme object from scratch.
string get_example_icon_name()
Gets the name of an icon that is representative of the current theme (for instance, to use when presenting a list of themes to the user.)
array get_icon_sizes(string name)
Returns an array of integers describing the sizes at which the icon is available without scaling. A size of -1 means that the icon is available in a scalable format.
array get_search_path()
Gets the current search path.
int has_icon(string icon_name)
Checks whether this icon theme includes an icon for a particular name.
array list_icons(string|void context)
Lists the icons in the current icon theme. Only a subset of the icons can be listed by providing a context string. The set of values for the context string is system dependent, but will typically include such values as 'apps' and 'mimetypes'.
GTK2.GdkPixbuf load_icon(string name, int size, int flags)
Looks up an icon in an icon theme, scales it to the given size and renders it into a pixbuf.
GTK2.IconInfo lookup_icon(string name, int size, int flags)
Looks up a named icon and returns an object containing information such as the filename of the icon. The icon can then be rendered into a pixbuf using GTK2.IconInfo->load_icon().
GTK2.IconTheme prepend_search_path(string path)
Prepends a directory to the search path.
int rescan_if_needed()
Checks to see if the icon theme has changed; if it has, any currently cached information is discarded and will be reloaded next time this theme is accessed.
GTK2.IconTheme set_custom_theme(string theme_name)
Sets the name of the icon theme that the GTK2.IconTheme object uses overriding system configuration. This function cannot be called on the icon theme objects return from get_default().
GTK2.IconTheme set_search_path(array path)
Sets the search path for the icon theme object. When looking for an icon theme, GTK2+ will search for a subdirectory of one or more of the directories in path with the same name as the icon theme. (Themes from multiple of the path elemets are combined to allow themes to be extended by adding icons in the user's home directory.)
In addition if an icon found isn't found either in the current icon theme or the default icon theme, and an image file with the right name is found directly in one of the elements of path, then that image will be used for the icon name. (This is a legacy feature, and new icons should be put into the default icon theme, which is called DEFAULT_THEME_NAME, rather than directly on the icon path.)
| CLASS GTK2.Frame |
The frame widget is a Bin that surrounds its child with a decorative frame and an optional label. If present, the label is drawn in a gap in the top side of the frame. The position of the label can be controlled with set_label_align().
Used to visually group objects.
GTK2.Frame("Title")->add(GTK2.Label("Contents"))
![]()
GTK2.Frame()->add(GTK2.Label("Contents"))
![]()
GTK2.Frame()->add(GTK2.Label("Contents"))->set_shadow_type(GTK2.SHADOW_IN)
![]()
Properties: string label GTK2.Widget label-widget float label-xalign float label-yalign int shadow int shadow-type
inherit GTK2.Bin : Bin
GTK2.Frame GTK2.Frame(string|mapping label_or_props)
Create a new W(Frame) widget.
string get_label()
Return the text in the label widget.
array get_label_align()
Retrieves the x and y alignment of the label.
GTK2.Widget get_label_widget()
Retrieves the label widget.
int get_shadow_type()
Return the shadow type.
GTK2.Frame set_label(string|void label_text)
Set the text of the label.
GTK2.Frame set_label_align(float xalign, float yalign)
Arguments are xalignment and yalignment. 0.0 is left or topmost, 1.0 is right or bottommost. The default value for a newly created Frame is 0.0.
GTK2.Frame set_label_widget(GTK2.Widget label)
Sets the label widget for the frame. This is the widget that will appear embedded in the top edge of the frame as a title.
GTK2.Frame set_shadow_type(int shadow_type)
Set the shadow type for the Frame widget. The type is one of SHADOW_ETCHED_IN , SHADOW_ETCHED_OUT , SHADOW_IN , SHADOW_NONE and SHADOW_OUT
| CLASS GTK2.Gnome2App |
Toplevel GNOME applications would normally use one Gnome2.App widget as their toplevel window. You can create as many Gnome2.App widgets as you want, for example, some people use one GnomeApp per document their application loads.
Once you have created one instance of this widget, you would add your main application view information to this window by using set_contents() routine.
The GnomeApp has support for including a menubar, one or more toolbars and a statusbar for your application. It also takes care of intalling the accelerators for you when used in conjuction with the gnome-app-helper routines. The toolbars are inserted into Gnome2.Dock widgets.
The gnome-app-helper module provides various helper routines to simplify the configuration of your menus and toolbars, but you can create those yourself and use the set_menus(), add_toolbar(), set_toolbar(), add_dock_item() and add_docked(). Properties: string app-id
inherit GTK2.Window : Window
Gnome2.App add_docked(GTK2.Widget widget, string name, int behavior, int placement, int band_num, int band_position, int|void offset)
Create a new Gnome2.DockItem widget containing widget, and add it to app's dock with the specified layout information. Notice that, if automatic layout configuration is enabled, the layout is overridden by the saved configuration, if any.
widget : Widget to be added to app's dock name : Name for the dock item that will contain toolbar behavior : Behavior for the new dock item. One of placement : Placement for the new dock item, one of Gnome2.DockTop, Gnome2.DockRight, Gnome2.DockBottom, Gnome2.DockLeft and Gnome2.DockFloating band_num : Number of the band where the dock item should be placed band_position : Position of the new dock item in band band_num offset : Offset from the previous dock item in the band; if there is no previous item, offset from the beginning of the band.
Gnome2.App add_toolbar(GTK2.Toolbar toolbar, string name, int behavior, int placement, int band_num, int band_position, int|void offset)
Create a new Gnome2.DockItem widget containing toolbar, and add it to app's dock with the specified layout information. Notice that, if automatic layout configuration is enabled, the layout is overridden by the saved configuration, if any.
toolbar : Toolbar to be added to app's dock name : Name for the dock item that will contain toolbar behavior : Behavior for the new dock item. One or more of placement : Placement for the new dock item, one of Gnome2.DockTop, Gnome2.DockRight, Gnome2.DockBottom, Gnome2.DockLeft and Gnome2.DockFloating band_num : Number of the band where the dock item should be placed band_position : Position of the new dock item in band band_num offset : Offset from the previous dock item in the band; if there is no previous item, offset from the beginning of the band.
Gnome2.App GTK2.Gnome2App(string appname, string|void title)
Create a new (empty) application window. You must specify the application's name (used internally as an identifier). title can be left as 0, in which case the window's title will not be set.
Gnome2.App enable_layout_config(int enable)
Specify whether the the dock's layout configuration should be automatically saved via gnome-config whenever it changes, or not.
Gnome2.App set_contents(GTK2.Widget contents)
Sets the status bar of the application window.
Gnome2.App set_menus(GTK2.MenuBar menu_bar)
Sets the menu bar of the application window.
Gnome2.App set_statusbar(GTK2.Widget statusbar)
Sets the status bar of the application window.
Gnome2.App set_statusbar_custom(GTK2.Widget container, GTK2.Widget statusbar)
Sets the status bar of the application window, but use container as its container.
Gnome2.App set_toolbar(GTK2.Toolbar toolbar)
Sets the main toolbar of the application window.
| CLASS GTK2.Pango.FontDescription |
Pango Font Description.
int better_match(GTK2.Pango.FontDescription new, GTK2.Pango.FontDescription old)
Determines if the style attributes of new are a closer match than old, or if old is omitted, determines if new is a match at all. Approximate matching is done for weight and style; other attributes must match exactly.
GTK2.Pango.FontDescription copy()
Copy a font description.
Pango.FontDescription GTK2.Pango.FontDescription(string|void desc)
Create a new font description. If desc is present, creates a new font description from a string representation in the form "[FAMILY-LIST] [STYLE-OPTIONS] [SIZE]", where FAMILY-LIST is a comma separated list of families optionally terminated by a comma, STYLE-OPTIONS is a whitespace separated list of words where each word describes one of style, variant, weight, or stretch, and size is a decimal number (size in points). Any one of the options may be absent. If FAMILY-LIST is absent, then the family name will be blank. If STYLE-OPTIONS is missing, then all style options will be set to the default values. If SIZE is missing, the size in the resulting font description will be set to 0.
int equal(GTK2.Pango.FontDescription desc)
Compares two font descriptions for equality.
string get_family()
Gets the family name.
int get_size()
Gets the size.
int get_stretch()
Get the stretch.
int get_style()
Gets the style.
int get_variant()
Gets the variant.
int get_weight()
Gets the weight.
Pango.FontDescription merge(GTK2.Pango.FontDescription desc, int replace)
Merges the fields that are set int desc to the fields in this description. If replace is false, only fields in this description that are not already set are affected. If true, then fields that are already set will be replaced as well.
Pango.FontDescription set_family(string family)
Sets the family name. The family name represents a family of related fonts styles, and will resolve to a particular PangoFontFamily.
Pango.FontDescription set_size(int size)
Sets the size in fractional points. This is the size of the font in points, scaled by PANGO_SCALE. (That is, a size value of 10*PANGO_SCALE) is a 10 point font. The conversion factor between points and device units depends on system configuration and the output device. For screen display, a logical DPI of 96 is common, in which case a 10 point font corresponds to a 1o*(96.72) = 13.3 pixel font. Use set_absolute_size() if you need a particular size in device units.
Pango.FontDescription set_stretch(int stretch)
Sets the stretch. This specifies how narrow or wide the font should be. One of PANGO_STRETCH_CONDENSED , PANGO_STRETCH_EXPANDED , PANGO_STRETCH_EXTRA_CONDENSED , PANGO_STRETCH_EXTRA_EXPANDED , PANGO_STRETCH_NORMAL , PANGO_STRETCH_SEMI_CONDENSED , PANGO_STRETCH_SEMI_EXPANDED , PANGO_STRETCH_ULTRA_CONDENSED and PANGO_STRETCH_ULTRA_EXPANDED .
Pango.FontDescription set_style(int style)
Sets the style. This describes whether the font is slanted and the manner in which is is slanted. One of PANGO_STYLE_ITALIC , PANGO_STYLE_NORMAL and PANGO_STYLE_OBLIQUE . Most fonts will either have an italic style or an oblique style, but not both, and font matching in Pango will match italic specifications with oblique fonts and vice-versa if an exact match is not found.
Pango.FontDescription set_variant(int variant)
Sets the variant. One of PANGO_VARIANT_NORMAL and PANGO_VARIANT_SMALL_CAPS .
Pango.FontDescription set_weight(int weight)
Sets the weight. The weight specifies how bold or light the font should be. In addition to the values of PANGO_WEIGHT_BOLD , PANGO_WEIGHT_HEAVY , PANGO_WEIGHT_LIGHT , PANGO_WEIGHT_NORMAL , PANGO_WEIGHT_ULTRABOLD and PANGO_WEIGHT_ULTRALIGHT , other intermediate numeric values are possible.
string to_filename()
Creates a filename representation. The filename is identical to the result from calling to_string(), but with underscores instead of characters that are untypical in filenames, and in lower case only.
string to_string()
Creates a string representation. The family list in the string description will only have a terminating comm if the last word of the list is a valid style option.
| CLASS GTK2.CheckMenuItem |
A check menu item is more or less identical to a check button, but it
should be used in menus.
GTK2.CheckMenuItem("Hi there")
![]()
GTK2.CheckMenuItem("Hi there")->set_active(1)
![]()
Properties: int active int draw-as-radio int inconsistent
Style properties: int indicator-size
Signals: toggled Called when the state of the menu item is changed
inherit GTK2.MenuItem : MenuItem
GTK2.CheckMenuItem GTK2.CheckMenuItem(string|mapping label_or_props)
The argument, if specified, is the label of the item. If no label is specified, use object->add() to add some other widget (such as an pixmap or image widget)
int get_active()
Get whether item is active.
int get_draw_as_radio()
Get whether check menu item is drawn like a radio button.
int get_inconsistent()
Retrieves the value set by set_inconsistent().
GTK2.CheckMenuItem set_active(int new_state)
State is either 1 or 0. If 1, the button will be 'pressed'.
GTK2.CheckMenuItem set_draw_as_radio(int draw_as_radio)
Set whether check menu item is drawn like a radio button.
GTK2.CheckMenuItem set_inconsistent(int setting)
If the user has selected a range of elements (such as some text or spreadsheet cells) that are affected by a boolean setting, and the current values in that range are inconsistent, you may want to display the check in an "in between" state. This function turns on "in between" display.
GTK2.CheckMenuItem toggled()
Emulate a toggled event
| CLASS GTK2.TextChildAnchor |
Anchors for embedding widgets in a TextBuffer.
inherit G.Object : Object
GTK2.TextChildAnchor GTK2.TextChildAnchor()
Creates a new W(TextChildAnchor). Usually you would then insert it into W(TextBuffer) with W(TextBuffer)->insert_child_anchor(). To perform the creation and insertion in one step, use the convenience function W(TextBuffer)->create_child_anchor().
int get_deleted()
Determines whether a child anchor has been deleted from the buffer.
array get_widgets()
Gets a list of all widgets anchored at this child anchor.
| CLASS GTK2.KeywordListTag |
inherit GTK2.SourceTag : SourceTag
GTK2.KeywordListTag GTK2.KeywordListTag(string id, string name, array keywords, int case_sensitive, int match_empty_string_at_beginning, int match_empty_string_at_end, string beginning_regex, string end_regex)
Creates a new keyword list tag object with the provided arguments.
| CLASS GTK2.Vbox |
Most packing is done by creating boxes. These are invisible widget containers that we can pack our widgets into which come in two forms, a horizontal box, and a vertical box. This is the vertical one. When packing widgets into a vertical box, the objects are inserted horizontally from top to bottom or bottom to top depending on the call used.
GTK2.Vbox(0,0)->add(GTK2.Button("Hello"))->add(GTK2.Button("World"))->pack_end_defaults(GTK2.Button("From right"))->pack_start_defaults(GTK2.Button("From left"))
![]()
GTK2.Vbox(1,0)->add(GTK2.Button("Hello"))->add(GTK2.Button("World"))->pack_end_defaults(GTK2.Button("From right"))->pack_start_defaults(GTK2.Button("From left"))
![]()
GTK2.Vbox(1,40)->add(GTK2.Button("Hello"))->add(GTK2.Button("World"))->pack_end_defaults(GTK2.Button("From right"))->pack_start_defaults(GTK2.Button("From left"))
![]()
inherit GTK2.Box : Box
GTK2.Vbox GTK2.Vbox(int|mapping uniformp_or_props, int|void padding)
Create a new vertical box widget. If all_same_size is true, all widgets will have exactly the same size. padding is added to the top and bottom of the children.
| CLASS GTK2.IconSize |
Iconsize.
int from_name(string name)
Looks up the icon size associated with name.
string get_name(int size)
Gets the canonical name of the given icon size.
int register(string name, int width, int height)
Registers a new icon size, along the same lines as GTK2.ICON_SIZE_MENU, etc. Returns the integer value for the size.
GTK2.IconSize register_alias(string alias, int target)
Registers alias as another name for target. So calling GTK2.IconSize->from_name() with alias will return target.
| CLASS GTK2.SourceTagTable |
Derived from GTK2.TextTagTable
Signals: changed
inherit GTK2.TextTagTable : TextTagTable
GTK2.SourceTagTable add_tags(array tags)
Adds a list of tags to the table. The added tags are assigned the highest priority in the table.
If a tag is already present in the table or has the same name as an already added tag, then it is not added to the table.
GTK2.SourceTagTable GTK2.SourceTagTable()
Creates a new table. The table contains no tags be default.
GTK2.SourceTagTable remove_source_tags()
Removes all source tags from the table. This will remove the table's reference to the tags, so be careful - tags will end up destroyed if you don't have a reference to them.
| CLASS GTK2.TreeSortable |
The interface for sortable models used by TreeView.
Signals: sort_column_changed
mapping get_sort_column_id()
Returns ([ "column": int, "order": int ])
int has_default_sort_func()
Returns true if the model has a default sort function.
GTK2.TreeSortable set_default_sort_func(function f, mixed user_data)
Sets the default comparison function used when sorting to be f. If the current sort column id of this sortable is GTK2.TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, then the model will sort using this function.
if f is 0, then there will be no default comparison function. This means once the model has been sorted, it can't go back to the default state. In this case, when the current sort column id of this sortable is GTK2.TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, the model will be unsorted.
GTK2.TreeSortable set_sort_column_id(int column, int order)
Sets the current sort column to be column. The widget will resort itself to reflect this change, after emitting a "sort-column-changed" signal. If column is GTK2.TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, then the default sort function will be used, if it is set.
GTK2.TreeSortable set_sort_func(int column, function f, mixed user_data)
Sets the comparison function used when sorting to be f. If the current sort column id of this sortable is the same as column, then the model will sort using this function.
GTK2.TreeSortable sort_column_changed()
Emits a "sort-column-changed" signal
| CLASS GTK2.ColorSelection |
The color selection widget is, not surprisingly, a widget for interactive selection of colors. This composite widget lets the user select a color by manipulating RGB (Red, Green, Blue) and HSV (Hue, Saturation, Value) triples. This is done either by adjusting single values with sliders or entries, or by picking the desired color from a hue-saturation wheel/value bar. Optionally, the opacity of the color can also be set.
The color selection widget currently emits only one signal, "color_changed", which is emitted whenever the current color in the widget changes, either when the user changes it or if it's set explicitly through set_color().
GTK2.ColorSelection()

Properties: int current-alpha GDK2.Color current-color int has-opacity-control int has-palette
Signals: color_changed
inherit GTK2.Vbox : Vbox
GTK2.ColorSelection GTK2.ColorSelection(mapping|void props)
Create a new color selection.
int get_current_alpha()
Returns the current alpha value.
mapping get_current_color()
When you need to query the current color, typically when you've received a "color_changed" signal, you use this function. The return value is an array of floats, See the set_color() function for the description of this array.
int get_has_opacity_control()
Determines whether the colorsel has an opacity control.
int get_has_palette()
Determines whether the color selector has a color palette.
int get_previous_alpha()
Returns the previous alpha value.
mapping get_previous_color()
Returns the original color value.
int is_adjusting()
Gets the current state of the colorsel.
GTK2.ColorSelection set_current_alpha(int alpha)
Sets the current opacity to be alpha. The first time this is called, it will also set the original opacity to be alpha too.
GTK2.ColorSelection set_current_color(mapping color)
You can set the current color explicitly by calling this function with an array of colors (floats). The length of the array depends on whether opacity is enabled or not. Position 0 contains the red component, 1 is green, 2 is blue and opacity is at position 3 (only if opacity is enabled, see set_opacity()) All values are between 0 and 65535
GTK2.ColorSelection set_has_opacity_control(int setting)
Sets whether or not to use opacity.
GTK2.ColorSelection set_has_palette(int has_palette)
Shows and hides the palette based upon the value of has_palette
GTK2.ColorSelection set_previous_alpha(int alpha)
Sets the 'previous' alpha to be alpha. This function should be called with some hesitation, as it might seem confusing to have that alpha change.
GTK2.ColorSelection set_previous_color(mapping colors)
Sets the 'previous' color to be color.
| CLASS GTK2.FontSelection |
The W(FontSelection) widget lists the available fonts, styles and sizes,
allowing the user to select a font. It is used in W(FontSelectionDialog).
GTK2.FontSelection();

Properties: string font-name string preview-text
inherit GTK2.Vbox : Vbox
GTK2.FontSelection GTK2.FontSelection(mapping|void props)
Create a new GTK2.FontSelection widget.
string get_font_name()
Gets the currently-selected font name.
string get_preview_text()
Gets the text displayed in the preview area.
GTK2.FontSelection set_font_name(string fontname)
This sets the currently displayed font.
GTK2.FontSelection set_preview_text(string text)
Sets the text displayed in the preview area.
| CLASS GTK2.Vseparator |
Simply creates a vertical separator. No bells or whistles.
GTK2.Vseparator()->set_size_request(3,50)
![]()
inherit GTK2.Separator : Separator
GTK2.Vseparator GTK2.Vseparator(mapping|void props)
Used to create a new vseparator widget.
| CLASS GTK2.CellRendererToggle |
Properties: int activatable The toggle button can be activated. int active The toggle state of the button. int inconsistent The inconsistent state of the button. int indicator-size int radio Draw the toggle butotn as a radio button.
Signals: toggled
inherit GTK2.CellRenderer : CellRenderer
GTK2.CellRendererToggle GTK2.CellRendererToggle(mapping|void props)
Creates a new W(CellRendererToggle). Adjust rendering parameters using object properties. Object properties can be set globally with set().
int get_active()
Returns whether the cell renderer is active.
int get_radio()
Returns whether we're rendering radio toggles rather than checkboxes.
GTK2.CellRendererToggle set_active(int setting)
Activates or deactivates a cell renderer.
GTK2.CellRendererToggle set_radio(int radio)
If radio is true, the cell renderer renders a radio toggle (i.e a toggle in a group of mutually-exclusive toggles). If false, it renders a check toggle (a standalone boolean option). This can be set globally for the cell renderer, or changed just before rendering each cell in the model (for W(TreeView), you set up a per-row setting using W(TreeViewColumn) to associate model columns with cell renderer properties).
| CLASS GTK2.Button |
A container that can only contain one child, and accepts events.
draws a bevelbox around itself.
GTK2.Button("A button")
![]()
GTK2.Button("A button\nwith multiple lines\nof text")

GTK2.Button()->add(GTK2.Image(GTK2.GdkImage(0)->set(Image.Image(100,40)->test())))

Properties: int focus-on-click GTK2.Widget image string label int relief int use-stock int use-underline float xalign float yalign
Style properties: int child-displacement-x int child-displacement-y GTK2.Border default-border GTK2.Border default-outside-border int displace-focus int image-spacing
Signals: activate
clicked Called when the button is pressed, and then released
enter Called when the mouse enters the button
leave Called when the mouse leaves the button
pressed Called when the button is pressed
released Called when the button is released
inherit GTK2.Bin : Bin
GTK2.Button clicked()
Emulate a 'clicked' event (press followed by release).
GTK2.Button GTK2.Button(string|mapping label_or_props)
If a string is supplied, a W(Label) is created and added to the button.
GTK2.Button enter()
Emulate a 'enter' event.
mapping get_alignment()
Gets the alignment of the child.
int get_focus_on_click()
Returns whether the button grabs focus when it is clicked.
GTK2.Widget get_image()
Gets the widget that is currently set as the image of the button.
string get_label()
Get the text from the label of the button.
int get_relief()
One of RELIEF_HALF , RELIEF_NONE and RELIEF_NORMAL , set with set_relief()
int get_use_stock()
Returns whether the button label is a stock item.
int get_use_underline()
Returns whether an embedded underline in the button indicates a mnemonic.
GTK2.Button leave()
Emulate a 'leave' event.
GTK2.Button pressed()
Emulate a 'press' event.
GTK2.Button released()
Emulate a 'release' event.
GTK2.Button set_alignment(float xalign, float yalign)
Sets the alignment of the child.
GTK2.Button set_focus_on_click(int focus_on_click)
Sets whether the button will grab focus when it is clicked.
GTK2.Button set_image(GTK2.Widget widget)
Set the image of the button to the given widget. Note that it depends on the gtk-button-images setting whether the image will be displayed or not.
GTK2.Button set_label(string label)
Set the text of the label.
GTK2.Button set_relief(int newstyle)
One of RELIEF_HALF , RELIEF_NONE and RELIEF_NORMAL
GTK2.Button set_use_stock(int use_stock)
If true, the label set on the button is used as a stock id to select the stock item for the button.
GTK2.Button set_use_underline(int use_underline)
If true, an underline in the text of the button label indicates the next character should be used for the mnemonic accelerator key.
| CLASS GTK2.TreeModelSort |
Properties: GTK2.TreeModel model
inherit G.Object : Object
inherit GTK2.TreeModel : TreeModel
inherit GTK2.TreeDragSource : TreeDragSource
inherit GTK2.TreeSortable : TreeSortable
GTK2.TreeIter convert_child_iter_to_iter(GTK2.TreeIter child_iter)
Returns an iter pointing to the row in this model that corresponds to the row pointed at by child_iter.
GTK2.TreePath convert_child_path_to_path(GTK2.TreePath child_path)
Converts child_path to a path relative to this model. That is, child_path points to a path in the child mode. The returned path will point to the same row in the sorted model.
GTK2.TreeIter convert_iter_to_child_iter(GTK2.TreeIter sorted_iter)
Returns an iter pointing to the row in this model that corresponds to the row pointed at by sorted_iter.
GTK2.TreePath convert_path_to_child_path(GTK2.TreePath sorted_path)
Converts sorted_path to a path on the child model.
GTK2.TreeModelSort GTK2.TreeModelSort(GTK2.TreeModel model)
Create a new GTK2.TreeModel, with model as the child model.
GTK2.TreeModel get_model()
Return the model this ModelSort is sorting.
GTK2.TreeModelSort reset_default_sort_func()
This resets the default sort function to be in the 'unsorted' state. That is, it is in the same order as the child model. It will re-sort the model to be in the same order as the child model only if this model is in 'unsorted' state.
| CLASS GTK2.PatternTag |
inherit GTK2.SourceTag : SourceTag
GTK2.PatternTag GTK2.PatternTag(string id, string name, string pattern)
Creates a new pattern tag object with the provided arguments.
| Module GTK |
inherit GTKSupport : GTKSupport
constant GTK.FALSE
constant GTK.GDK_ACTION_ASK
constant GTK.GDK_ACTION_COPY
constant GTK.GDK_ACTION_DEFAULT
constant GTK.GDK_ACTION_LINK
constant GTK.GDK_ACTION_MOVE
constant GTK.GDK_ACTION_PRIVATE
constant GTK.GDK_ALL_EVENTS_MASK
constant GTK.GDK_AND
constant GTK.GDK_AND_INVERT
constant GTK.GDK_AND_REVERSE
constant GTK.GDK_ARROW
constant GTK.GDK_BASED_ARROW_DOWN
constant GTK.GDK_BASED_ARROW_UP
constant GTK.GDK_BOAT
constant GTK.GDK_BOGOSITY
constant GTK.GDK_BOTTOM_LEFT_CORNER
constant GTK.GDK_BOTTOM_RIGHT_CORNER
constant GTK.GDK_BOTTOM_SIDE
constant GTK.GDK_BOTTOM_TEE
constant GTK.GDK_BOX_SPIRAL
constant GTK.GDK_BUTTON1_MASK
constant GTK.GDK_BUTTON1_MOTION_MASK
constant GTK.GDK_BUTTON2_MASK
constant GTK.GDK_BUTTON2_MOTION_MASK
constant GTK.GDK_BUTTON3_MASK
constant GTK.GDK_BUTTON3_MOTION_MASK
constant GTK.GDK_BUTTON_MOTION_MASK
constant GTK.GDK_BUTTON_PRESS_MASK
constant GTK.GDK_BUTTON_RELEASE_MASK
constant GTK.GDK_CAP_BUTT
constant GTK.GDK_CAP_NOT_LAST
constant GTK.GDK_CAP_PROJECTING
constant GTK.GDK_CAP_ROUND
constant GTK.GDK_CENTER_PTR
constant GTK.GDK_CIRCLE
constant GTK.GDK_CLEAR
constant GTK.GDK_CLOCK
constant GTK.GDK_COFFEE_MUG
constant GTK.GDK_CONTROL_MASK
constant GTK.GDK_COPY
constant GTK.GDK_COPY_INVERT
constant GTK.GDK_CROSS
constant GTK.GDK_CROSSHAIR
constant GTK.GDK_CROSS_REVERSE
constant GTK.GDK_DECOR_ALL
constant GTK.GDK_DECOR_BORDER
constant GTK.GDK_DECOR_MAXIMIZE
constant GTK.GDK_DECOR_MENU
constant GTK.GDK_DECOR_MINIMIZE
constant GTK.GDK_DECOR_RESIZEH
constant GTK.GDK_DECOR_TITLE
constant GTK.GDK_DIAMOND_CROSS
constant GTK.GDK_DOT
constant GTK.GDK_DOTBOX
constant GTK.GDK_DOUBLE_ARROW
constant GTK.GDK_DRAFT_LARGE
constant GTK.GDK_DRAFT_SMALL
constant GTK.GDK_DRAG_PROTO_MOTIF
constant GTK.GDK_DRAG_PROTO_ROOTWIN
constant GTK.GDK_DRAG_PROTO_XDND
constant GTK.GDK_DRAPED_BOX
constant GTK.GDK_ENTER_NOTIFY_MASK
constant GTK.GDK_EQUIV
constant GTK.GDK_EVEN_ODD_RULE
constant GTK.GDK_EXCHANGE
constant GTK.GDK_EXPOSURE_MASK
constant GTK.GDK_EXTENSION_EVENTS_ALL
constant GTK.GDK_EXTENSION_EVENTS_CURSOR
constant GTK.GDK_EXTENSION_EVENTS_NONE
constant GTK.GDK_FLEUR
constant GTK.GDK_FOCUS_CHANGE_MASK
constant GTK.GDK_FUNC_ALL
constant GTK.GDK_FUNC_CLOSE
constant GTK.GDK_FUNC_MAXIMIZE
constant GTK.GDK_FUNC_MINIMIZE
constant GTK.GDK_FUNC_MOVE
constant GTK.GDK_FUNC_RESIZE
constant GTK.GDK_GL_ACCUM_ALPHA_SIZE
constant GTK.GDK_GL_ACCUM_BLUE_SIZE
constant GTK.GDK_GL_ACCUM_GREEN_SIZE
constant GTK.GDK_GL_ACCUM_RED_SIZE
constant GTK.GDK_GL_ALPHA_SIZE
constant GTK.GDK_GL_AUX_BUFFERS
constant GTK.GDK_GL_BLUE_SIZE
constant GTK.GDK_GL_BUFFER_SIZE
constant GTK.GDK_GL_DEPTH_SIZE
constant GTK.GDK_GL_DOUBLEBUFFER
constant GTK.GDK_GL_GREEN_SIZE
constant GTK.GDK_GL_LEVEL
constant GTK.GDK_GL_NONE
constant GTK.GDK_GL_RED_SIZE
constant GTK.GDK_GL_RGBA
constant GTK.GDK_GL_STENCIL_SIZE
constant GTK.GDK_GL_STEREO
constant GTK.GDK_GL_TRANSPARENT_ALPHA_VALUE_EXT
constant GTK.GDK_GL_TRANSPARENT_BLUE_VALUE_EXT
constant GTK.GDK_GL_TRANSPARENT_GREEN_VALUE_EXT
constant GTK.GDK_GL_TRANSPARENT_INDEX_VALUE_EXT
constant GTK.GDK_GL_TRANSPARENT_RED_VALUE_EXT
constant GTK.GDK_GL_TRANSPARENT_TYPE_EXT
constant GTK.GDK_GL_USE_GL
constant GTK.GDK_GL_X_VISUAL_TYPE_EXT
constant GTK.GDK_GOBBLER
constant GTK.GDK_GUMBY
constant GTK.GDK_HAND1
constant GTK.GDK_HAND2
constant GTK.GDK_HEART
constant GTK.GDK_ICON
constant GTK.GDK_IM_PREEDIT_AREA
constant GTK.GDK_IM_PREEDIT_CALLBACKS
constant GTK.GDK_IM_PREEDIT_MASK
constant GTK.GDK_IM_PREEDIT_NONE
constant GTK.GDK_IM_PREEDIT_NOTHING
constant GTK.GDK_IM_PREEDIT_POSITION
constant GTK.GDK_IM_STATUS_AREA
constant GTK.GDK_IM_STATUS_CALLBACKS
constant GTK.GDK_IM_STATUS_MASK
constant GTK.GDK_IM_STATUS_NONE
constant GTK.GDK_IM_STATUS_NOTHING
constant GTK.GDK_INVERT
constant GTK.GDK_IRON_CROSS
constant GTK.GDK_JOIN_BEVEL
constant GTK.GDK_JOIN_MITER
constant GTK.GDK_JOIN_ROUND
constant GTK.GDK_KEY_PRESS_MASK
constant GTK.GDK_KEY_RELEASE_MASK
constant GTK.GDK_LEAVE_NOTIFY_MASK
constant GTK.GDK_LEFTBUTTON
constant GTK.GDK_LEFT_PTR
constant GTK.GDK_LEFT_SIDE
constant GTK.GDK_LEFT_TEE
constant GTK.GDK_LINE_DOUBLE_DASH
constant GTK.GDK_LINE_ON_OFF_DASH
constant GTK.GDK_LINE_SOLID
constant GTK.GDK_LL_ANGLE
constant GTK.GDK_LOCK_MASK
constant GTK.GDK_LR_ANGLE
constant GTK.GDK_MAN
constant GTK.GDK_MIDDLEBUTTON
constant GTK.GDK_MOD1_MASK
constant GTK.GDK_MOD2_MASK
constant GTK.GDK_MOD3_MASK
constant GTK.GDK_MOD4_MASK
constant GTK.GDK_MOD5_MASK
constant GTK.GDK_MOUSE
constant GTK.GDK_NAND
constant GTK.GDK_NOOP
constant GTK.GDK_OPAQUE_STIPPLED
constant GTK.GDK_OR
constant GTK.GDK_OR_INVERT
constant GTK.GDK_OR_REVERSE
constant GTK.GDK_OVERLAP_RECTANGLE_IN
constant GTK.GDK_OVERLAP_RECTANGLE_OUT
constant GTK.GDK_OVERLAP_RECTANGLE_PART
constant GTK.GDK_PENCIL
constant GTK.GDK_PIRATE
constant GTK.GDK_PLUS
constant GTK.GDK_POINTER_MOTION_HINT_MASK
constant GTK.GDK_POINTER_MOTION_MASK
constant GTK.GDK_PROPERTY_CHANGE_MASK
constant GTK.GDK_PROP_MODE_APPEND
constant GTK.GDK_PROP_MODE_PREPEND
constant GTK.GDK_PROP_MODE_REPLACE
constant GTK.GDK_PROXIMITY_IN_MASK
constant GTK.GDK_PROXIMITY_OUT_MASK
constant GTK.GDK_QUESTION_ARROW
constant GTK.GDK_RIGHTBUTTON
constant GTK.GDK_RIGHT_PTR
constant GTK.GDK_RIGHT_SIDE
constant GTK.GDK_RIGHT_TEE
constant GTK.GDK_RTL_LOGO
constant GTK.GDK_SAILBOAT
constant GTK.GDK_SB_DOWN_ARROW
constant GTK.GDK_SB_H_DOUBLE_ARROW
constant GTK.GDK_SB_LEFT_ARROW
constant GTK.GDK_SB_RIGHT_ARROW
constant GTK.GDK_SB_UP_ARROW
constant GTK.GDK_SB_V_DOUBLE_ARROW
constant GTK.GDK_SELECTION_TYPE_ATOM
constant GTK.GDK_SELECTION_TYPE_BITMAP
constant GTK.GDK_SELECTION_TYPE_COLORMAP
constant GTK.GDK_SELECTION_TYPE_DRAWABLE
constant GTK.GDK_SELECTION_TYPE_INTEGER
constant GTK.GDK_SELECTION_TYPE_PIXMAP
constant GTK.GDK_SELECTION_TYPE_STRING
constant GTK.GDK_SELECTION_TYPE_WINDOW
constant GTK.GDK_SET
constant GTK.GDK_SHIFT_MASK
constant GTK.GDK_SHUTTLE
constant GTK.GDK_SIZING
constant GTK.GDK_SOLID
constant GTK.GDK_SPIDER
constant GTK.GDK_SPRAYCAN
constant GTK.GDK_STAR
constant GTK.GDK_STIPPLED
constant GTK.GDK_STRUCTURE_MASK
constant GTK.GDK_TARGET
constant GTK.GDK_TARGET_BITMAP
constant GTK.GDK_TARGET_COLORMAP
constant GTK.GDK_TARGET_DRAWABLE
constant GTK.GDK_TARGET_PIXMAP
constant GTK.GDK_TARGET_STRING
constant GTK.GDK_TCROSS
constant GTK.GDK_TILED
constant GTK.GDK_TOP_LEFT_ARROW
constant GTK.GDK_TOP_LEFT_CORNER
constant GTK.GDK_TOP_RIGHT_CORNER
constant GTK.GDK_TOP_SIDE
constant GTK.GDK_TOP_TEE
constant GTK.GDK_TREK
constant GTK.GDK_UL_ANGLE
constant GTK.GDK_UMBRELLA
constant GTK.GDK_UR_ANGLE
constant GTK.GDK_VISIBILITY_NOTIFY_MASK
constant GTK.GDK_WATCH
constant GTK.GDK_WINDING_RULE
constant GTK.GDK_WINDOW_CHILD
constant GTK.GDK_WINDOW_DIALOG
constant GTK.GDK_WINDOW_FOREIGN
constant GTK.GDK_WINDOW_ROOT
constant GTK.GDK_WINDOW_TEMP
constant GTK.GDK_WINDOW_TOPLEVEL
constant GTK.GDK_XOR
constant GTK.GDK_XTERM
constant GTK.GNOME_DOCK_BOTTOM
constant GTK.GNOME_DOCK_ITEM_BEH_EXCLUSIVE
constant GTK.GNOME_DOCK_ITEM_BEH_LOCKED
constant GTK.GNOME_DOCK_ITEM_BEH_NEVER_FLOATING
constant GTK.GNOME_DOCK_ITEM_BEH_NEVER_HORIZONTAL
constant GTK.GNOME_DOCK_ITEM_BEH_NEVER_VERTICAL
constant GTK.GNOME_DOCK_ITEM_BEH_NORMAL
constant GTK.GNOME_DOCK_LEFT
constant GTK.GNOME_DOCK_RIGHT
constant GTK.GNOME_DOCK_TOP
constant GTK.GNOME_FONT_PICKER_MODE_FONT_INFO
constant GTK.GNOME_FONT_PICKER_MODE_PIXMAP
constant GTK.GNOME_FONT_PICKER_MODE_UNKNOWN
constant GTK.GNOME_FONT_PICKER_MODE_USER_WIDGET
constant GTK.GNOME_ICON_LIST_ICONS
constant GTK.GNOME_ICON_LIST_IS_EDITABLE
constant GTK.GNOME_ICON_LIST_STATIC_TEXT
constant GTK.GNOME_ICON_LIST_TEXT_BELOW
constant GTK.GNOME_ICON_LIST_TEXT_RIGHT
constant GTK.GNOME_MESSAGE_BOX_ERROR
constant GTK.GNOME_MESSAGE_BOX_GENERIC
constant GTK.GNOME_MESSAGE_BOX_INFO
constant GTK.GNOME_MESSAGE_BOX_QUESTION
constant GTK.GNOME_MESSAGE_BOX_WARNING
constant GTK.GNOME_PREFERENCES_ALWAYS
constant GTK.GNOME_PREFERENCES_NEVER
constant GTK.GNOME_PREFERENCES_USER
constant GTK.GNOME_Panel_ORIENT_DOWN
constant GTK.GNOME_Panel_ORIENT_LEFT
constant GTK.GNOME_Panel_ORIENT_RIGHT
constant GTK.GNOME_Panel_ORIENT_UP
constant GTK.GNOME_STOCK_BUTTON_APPLY
constant GTK.GNOME_STOCK_BUTTON_CANCEL
constant GTK.GNOME_STOCK_BUTTON_CLOSE
constant GTK.GNOME_STOCK_BUTTON_DOWN
constant GTK.GNOME_STOCK_BUTTON_FONT
constant GTK.GNOME_STOCK_BUTTON_HELP
constant GTK.GNOME_STOCK_BUTTON_NEXT
constant GTK.GNOME_STOCK_BUTTON_NO
constant GTK.GNOME_STOCK_BUTTON_OK
constant GTK.GNOME_STOCK_BUTTON_PREV
constant GTK.GNOME_STOCK_BUTTON_UP
constant GTK.GNOME_STOCK_BUTTON_YES
constant GTK.GNOME_STOCK_MENU_ABOUT
constant GTK.GNOME_STOCK_MENU_ALIGN_CENTER
constant GTK.GNOME_STOCK_MENU_ALIGN_JUSTIFY
constant GTK.GNOME_STOCK_MENU_ALIGN_LEFT
constant GTK.GNOME_STOCK_MENU_ALIGN_RIGHT
constant GTK.GNOME_STOCK_MENU_ATTACH
constant GTK.GNOME_STOCK_MENU_BACK
constant GTK.GNOME_STOCK_MENU_BLANK
constant GTK.GNOME_STOCK_MENU_BOOK_BLUE
constant GTK.GNOME_STOCK_MENU_BOOK_GREEN
constant GTK.GNOME_STOCK_MENU_BOOK_OPEN
constant GTK.GNOME_STOCK_MENU_BOOK_RED
constant GTK.GNOME_STOCK_MENU_BOOK_YELLOW
constant GTK.GNOME_STOCK_MENU_BOTTOM
constant GTK.GNOME_STOCK_MENU_CDROM
constant GTK.GNOME_STOCK_MENU_CLOSE
constant GTK.GNOME_STOCK_MENU_CONVERT
constant GTK.GNOME_STOCK_MENU_COPY
constant GTK.GNOME_STOCK_MENU_CUT
constant GTK.GNOME_STOCK_MENU_DOWN
constant GTK.GNOME_STOCK_MENU_EXEC
constant GTK.GNOME_STOCK_MENU_EXIT
constant GTK.GNOME_STOCK_MENU_FIRST
constant GTK.GNOME_STOCK_MENU_FONT
constant GTK.GNOME_STOCK_MENU_FORWARD
constant GTK.GNOME_STOCK_MENU_HOME
constant GTK.GNOME_STOCK_MENU_INDEX
constant GTK.GNOME_STOCK_MENU_JUMP_TO
constant GTK.GNOME_STOCK_MENU_LAST
constant GTK.GNOME_STOCK_MENU_LINE_IN
constant GTK.GNOME_STOCK_MENU_MAIL
constant GTK.GNOME_STOCK_MENU_MAIL_FWD
constant GTK.GNOME_STOCK_MENU_MAIL_NEW
constant GTK.GNOME_STOCK_MENU_MAIL_RCV
constant GTK.GNOME_STOCK_MENU_MAIL_RPL
constant GTK.GNOME_STOCK_MENU_MAIL_SND
constant GTK.GNOME_STOCK_MENU_MIC
constant GTK.GNOME_STOCK_MENU_MIDI
constant GTK.GNOME_STOCK_MENU_NEW
constant GTK.GNOME_STOCK_MENU_OPEN
constant GTK.GNOME_STOCK_MENU_PASTE
constant GTK.GNOME_STOCK_MENU_PREF
constant GTK.GNOME_STOCK_MENU_PRINT
constant GTK.GNOME_STOCK_MENU_PROP
constant GTK.GNOME_STOCK_MENU_QUIT
constant GTK.GNOME_STOCK_MENU_REDO
constant GTK.GNOME_STOCK_MENU_REFRESH
constant GTK.GNOME_STOCK_MENU_REVERT
constant GTK.GNOME_STOCK_MENU_SAVE
constant GTK.GNOME_STOCK_MENU_SAVE_AS
constant GTK.GNOME_STOCK_MENU_SCORES
constant GTK.GNOME_STOCK_MENU_SEARCH
constant GTK.GNOME_STOCK_MENU_SPELLCHECK
constant GTK.GNOME_STOCK_MENU_SRCHRPL
constant GTK.GNOME_STOCK_MENU_STOP
constant GTK.GNOME_STOCK_MENU_TEXT_BOLD
constant GTK.GNOME_STOCK_MENU_TEXT_ITALIC
constant GTK.GNOME_STOCK_MENU_TEXT_STRIKEOUT
constant GTK.GNOME_STOCK_MENU_TEXT_UNDERLINE
constant GTK.GNOME_STOCK_MENU_TIMER
constant GTK.GNOME_STOCK_MENU_TIMER_STOP
constant GTK.GNOME_STOCK_MENU_TOP
constant GTK.GNOME_STOCK_MENU_TRASH
constant GTK.GNOME_STOCK_MENU_TRASH_FULL
constant GTK.GNOME_STOCK_MENU_UNDELETE
constant GTK.GNOME_STOCK_MENU_UNDO
constant GTK.GNOME_STOCK_MENU_UP
constant GTK.GNOME_STOCK_MENU_VOLUME
constant GTK.GNOME_STOCK_PIXMAP_ABOUT
constant GTK.GNOME_STOCK_PIXMAP_ADD
constant GTK.GNOME_STOCK_PIXMAP_ALIGN_CENTER
constant GTK.GNOME_STOCK_PIXMAP_ALIGN_JUSTIFY
constant GTK.GNOME_STOCK_PIXMAP_ALIGN_LEFT
constant GTK.GNOME_STOCK_PIXMAP_ALIGN_RIGHT
constant GTK.GNOME_STOCK_PIXMAP_ATTACH
constant GTK.GNOME_STOCK_PIXMAP_BACK
constant GTK.GNOME_STOCK_PIXMAP_BOOK_BLUE
constant GTK.GNOME_STOCK_PIXMAP_BOOK_GREEN
constant GTK.GNOME_STOCK_PIXMAP_BOOK_OPEN
constant GTK.GNOME_STOCK_PIXMAP_BOOK_RED
constant GTK.GNOME_STOCK_PIXMAP_BOOK_YELLOW
constant GTK.GNOME_STOCK_PIXMAP_BOTTOM
constant GTK.GNOME_STOCK_PIXMAP_CDROM
constant GTK.GNOME_STOCK_PIXMAP_CLEAR
constant GTK.GNOME_STOCK_PIXMAP_CLOSE
constant GTK.GNOME_STOCK_PIXMAP_COLORSELECTOR
constant GTK.GNOME_STOCK_PIXMAP_CONVERT
constant GTK.GNOME_STOCK_PIXMAP_COPY
constant GTK.GNOME_STOCK_PIXMAP_CUT
constant GTK.GNOME_STOCK_PIXMAP_DISABLED
constant GTK.GNOME_STOCK_PIXMAP_DOWN
constant GTK.GNOME_STOCK_PIXMAP_EXEC
constant GTK.GNOME_STOCK_PIXMAP_EXIT
constant GTK.GNOME_STOCK_PIXMAP_FIRST
constant GTK.GNOME_STOCK_PIXMAP_FOCUSED
constant GTK.GNOME_STOCK_PIXMAP_FONT
constant GTK.GNOME_STOCK_PIXMAP_FORWARD
constant GTK.GNOME_STOCK_PIXMAP_HELP
constant GTK.GNOME_STOCK_PIXMAP_HOME
constant GTK.GNOME_STOCK_PIXMAP_INDEX
constant GTK.GNOME_STOCK_PIXMAP_JUMP_TO
constant GTK.GNOME_STOCK_PIXMAP_LAST
constant GTK.GNOME_STOCK_PIXMAP_LINE_IN
constant GTK.GNOME_STOCK_PIXMAP_MAIL
constant GTK.GNOME_STOCK_PIXMAP_MAIL_FWD
constant GTK.GNOME_STOCK_PIXMAP_MAIL_NEW
constant GTK.GNOME_STOCK_PIXMAP_MAIL_RCV
constant GTK.GNOME_STOCK_PIXMAP_MAIL_RPL
constant GTK.GNOME_STOCK_PIXMAP_MAIL_SND
constant GTK.GNOME_STOCK_PIXMAP_MIC
constant GTK.GNOME_STOCK_PIXMAP_MIDI
constant GTK.GNOME_STOCK_PIXMAP_MULTIPLE
constant GTK.GNOME_STOCK_PIXMAP_NEW
constant GTK.GNOME_STOCK_PIXMAP_NOT
constant GTK.GNOME_STOCK_PIXMAP_OPEN
constant GTK.GNOME_STOCK_PIXMAP_PASTE
constant GTK.GNOME_STOCK_PIXMAP_PREFERENCES
constant GTK.GNOME_STOCK_PIXMAP_PRINT
constant GTK.GNOME_STOCK_PIXMAP_PROPERTIES
constant GTK.GNOME_STOCK_PIXMAP_QUIT
constant GTK.GNOME_STOCK_PIXMAP_REDO
constant GTK.GNOME_STOCK_PIXMAP_REFRESH
constant GTK.GNOME_STOCK_PIXMAP_REGULAR
constant GTK.GNOME_STOCK_PIXMAP_REMOVE
constant GTK.GNOME_STOCK_PIXMAP_REVERT
constant GTK.GNOME_STOCK_PIXMAP_SAVE
constant GTK.GNOME_STOCK_PIXMAP_SAVE_AS
constant GTK.GNOME_STOCK_PIXMAP_SCORES
constant GTK.GNOME_STOCK_PIXMAP_SEARCH
constant GTK.GNOME_STOCK_PIXMAP_SPELLCHECK
constant GTK.GNOME_STOCK_PIXMAP_SRCHRPL
constant GTK.GNOME_STOCK_PIXMAP_STOP
constant GTK.GNOME_STOCK_PIXMAP_TABLE_BORDERS
constant GTK.GNOME_STOCK_PIXMAP_TABLE_FILL
constant GTK.GNOME_STOCK_PIXMAP_TEXT_BOLD
constant GTK.GNOME_STOCK_PIXMAP_TEXT_BULLETED_LIST
constant GTK.GNOME_STOCK_PIXMAP_TEXT_INDENT
constant GTK.GNOME_STOCK_PIXMAP_TEXT_ITALIC
constant GTK.GNOME_STOCK_PIXMAP_TEXT_NUMBERED_LIST
constant GTK.GNOME_STOCK_PIXMAP_TEXT_STRIKEOUT
constant GTK.GNOME_STOCK_PIXMAP_TEXT_UNDERLINE
constant GTK.GNOME_STOCK_PIXMAP_TEXT_UNINDENT
constant GTK.GNOME_STOCK_PIXMAP_TIMER
constant GTK.GNOME_STOCK_PIXMAP_TIMER_STOP
constant GTK.GNOME_STOCK_PIXMAP_TOP
constant GTK.GNOME_STOCK_PIXMAP_TRASH
constant GTK.GNOME_STOCK_PIXMAP_TRASH_FULL
constant GTK.GNOME_STOCK_PIXMAP_TYPE_DATA
constant GTK.GNOME_STOCK_PIXMAP_TYPE_FILE
constant GTK.GNOME_STOCK_PIXMAP_TYPE_GPIXMAP
constant GTK.GNOME_STOCK_PIXMAP_TYPE_IMLIB
constant GTK.GNOME_STOCK_PIXMAP_TYPE_IMLIB_SCALED
constant GTK.GNOME_STOCK_PIXMAP_TYPE_NONE
constant GTK.GNOME_STOCK_PIXMAP_TYPE_PATH
constant GTK.GNOME_STOCK_PIXMAP_TYPE_WIDGET
constant GTK.GNOME_STOCK_PIXMAP_UNDELETE
constant GTK.GNOME_STOCK_PIXMAP_UNDO
constant GTK.GNOME_STOCK_PIXMAP_UP
constant GTK.GNOME_STOCK_PIXMAP_VOLUME
constant GTK.ACCEL_LOCKED
constant GTK.ACCEL_SIGNAL_VISIBLE
constant GTK.ACCEL_VISIBLE
constant GTK.ANCHOR_CENTER
constant GTK.ANCHOR_E
constant GTK.ANCHOR_EAST
constant GTK.ANCHOR_N
constant GTK.ANCHOR_NE
constant GTK.ANCHOR_NORTH
constant GTK.ANCHOR_NORTH_EAST
constant GTK.ANCHOR_NORTH_WEST
constant GTK.ANCHOR_NW
constant GTK.ANCHOR_S
constant GTK.ANCHOR_SE
constant GTK.ANCHOR_SOUTH
constant GTK.ANCHOR_SOUTH_EAST
constant GTK.ANCHOR_SOUTH_WEST
constant GTK.ANCHOR_SW
constant GTK.ANCHOR_W
constant GTK.ANCHOR_WEST
constant GTK.APP_PAINTABLE
constant GTK.ARROW_DOWN
constant GTK.ARROW_LEFT
constant GTK.ARROW_RIGHT
constant GTK.ARROW_UP
constant GTK.BUTTONBOX_DEFAULT_STYLE
constant GTK.BUTTONBOX_EDGE
constant GTK.BUTTONBOX_END
constant GTK.BUTTONBOX_SPREAD
constant GTK.BUTTONBOX_START
constant GTK.BUTTON_DRAGS
constant GTK.BUTTON_EXPANDS
constant GTK.BUTTON_IGNORED
constant GTK.BUTTON_SELECTS
constant GTK.CALENDAR_NO_MONTH_CHANGE
constant GTK.CALENDAR_SHOW_DAY_NAMES
constant GTK.CALENDAR_SHOW_HEADING
constant GTK.CALENDAR_SHOW_WEEK_NUMBERS
constant GTK.CALENDAR_WEEK_START_MONDAY
constant GTK.CAN_DEFAULT
constant GTK.CAN_FOCUS
constant GTK.CELL_EMPTY
constant GTK.CELL_PIXMAP
constant GTK.CELL_PIXTEXT
constant GTK.CELL_TEXT
constant GTK.CELL_WIDGET
constant GTK.CENTIMETERS
constant GTK.CLIST_ADD_MODE
constant GTK.CLIST_AUTO_RESIZE_BLOCKED
constant GTK.CLIST_AUTO_SORT
constant GTK.CLIST_DRAW_DRAG_LINE
constant GTK.CLIST_DRAW_DRAG_RECT
constant GTK.CLIST_IN_DRAG
constant GTK.CLIST_REORDERABLE
constant GTK.CLIST_ROW_HEIGHT_SET
constant GTK.CLIST_SHOW_TITLES
constant GTK.CLIST_USE_DRAG_ICONS
constant GTK.CLOCK_DECREASING
constant GTK.CLOCK_INCREASING
constant GTK.CLOCK_REALTIME
constant GTK.COMPOSITE_CHILD
constant GTK.CORNER_BOTTOM_LEFT
constant GTK.CORNER_BOTTOM_RIGHT
constant GTK.CORNER_TOP_LEFT
constant GTK.CORNER_TOP_RIGHT
constant GTK.CTREE_EXPANDER_CIRCULAR
constant GTK.CTREE_EXPANDER_NONE
constant GTK.CTREE_EXPANDER_SQUARE
constant GTK.CTREE_EXPANDER_TRIANGLE
constant GTK.CTREE_EXPANSION_COLLAPSE
constant GTK.CTREE_EXPANSION_COLLAPSE_RECURSIVE
constant GTK.CTREE_EXPANSION_EXPAND
constant GTK.CTREE_EXPANSION_EXPAND_RECURSIVE
constant GTK.CTREE_EXPANSION_TOGGLE
constant GTK.CTREE_EXPANSION_TOGGLE_RECURSIVE
constant GTK.CTREE_LINES_DOTTED
constant GTK.CTREE_LINES_NONE
constant GTK.CTREE_LINES_SOLID
constant GTK.CTREE_LINES_TABBED
constant GTK.CTREE_POS_AFTER
constant GTK.CTREE_POS_AS_CHILD
constant GTK.CTREE_POS_BEFORE
constant GTK.CURVE_TYPE_FREE
constant GTK.CURVE_TYPE_LINEAR
constant GTK.CURVE_TYPE_SPLINE
constant GTK.DATABOX_BARS
constant GTK.DATABOX_LINES
constant GTK.DATABOX_NOT_DISPLAYED
constant GTK.DATABOX_POINTS
constant GTK.DEST_DEFAULT_ALL
constant GTK.DEST_DEFAULT_DROP
constant GTK.DEST_DEFAULT_HIGHLIGHT
constant GTK.DEST_DEFAULT_MOTION
constant GTK.DIRECTION_LEFT
constant GTK.DIRECTION_RIGHT
constant GTK.DIR_DOWN
constant GTK.DIR_LEFT
constant GTK.DIR_RIGHT
constant GTK.DIR_TAB_BACKWARD
constant GTK.DIR_TAB_FORWARD
constant GTK.DIR_UP
constant GTK.EXPAND
constant GTK.FILL
constant GTK.FILL_X
constant GTK.FILL_Y
constant GTK.HAS_DEFAULT
constant GTK.HAS_FOCUS
constant GTK.HAS_GRAB
constant GTK.INCHES
constant GTK.JUSTIFY_CENTER
constant GTK.JUSTIFY_FILL
constant GTK.JUSTIFY_LEFT
constant GTK.JUSTIFY_RIGHT
constant GTK.LEFT_RIGHT
constant GTK.MAPPED
constant GTK.NO_REPARENT
constant GTK.NO_WINDOW
constant GTK.ORIENTATION_HORIZONTAL
constant GTK.ORIENTATION_VERTICAL
constant GTK.PACK_END
constant GTK.PACK_EXPAND
constant GTK.PACK_START
constant GTK.PARENT_SENSITIVE
constant GTK.PIXELS
constant GTK.POLICY_ALWAYS
constant GTK.POLICY_AUTOMATIC
constant GTK.POLICY_NEVER
constant GTK.POS_BOTTOM
constant GTK.POS_LEFT
constant GTK.POS_RIGHT
constant GTK.POS_TOP
constant GTK.PREVIEW_COLOR
constant GTK.PREVIEW_GRAYSCALE
constant GTK.PROGRESS_BOTTOM_TO_TOP
constant GTK.PROGRESS_CONTINUOUS
constant GTK.PROGRESS_DISCRETE
constant GTK.PROGRESS_LEFT_TO_RIGHT
constant GTK.PROGRESS_RIGHT_TO_LEFT
constant GTK.PROGRESS_TOP_TO_BOTTOM
constant GTK.RC_STYLE
constant GTK.REALIZED
constant GTK.RELIEF_HALF
constant GTK.RELIEF_NONE
constant GTK.RELIEF_NORMAL
constant GTK.RESIZE_IMMEDIATE
constant GTK.RESIZE_PARENT
constant GTK.RESIZE_QUEUE
constant GTK.RUN_BOTH
constant GTK.RUN_FIRST
constant GTK.RUN_LAST
constant GTK.RUN_NO_RECURSE
constant GTK.SCROLL_JUMP
constant GTK.SCROLL_NONE
constant GTK.SCROLL_PAGE_BACKWARD
constant GTK.SCROLL_PAGE_FORWARD
constant GTK.SCROLL_STEP_BACKWARD
constant GTK.SCROLL_STEP_FORWARD
constant GTK.SELECTION_BROWSE
constant GTK.SELECTION_EXTENDED
constant GTK.SELECTION_MULTIPLE
constant GTK.SELECTION_SINGLE
constant GTK.SENSITIVE
constant GTK.SHADOW_ETCHED_IN
constant GTK.SHADOW_ETCHED_OUT
constant GTK.SHADOW_IN
constant GTK.SHADOW_NONE
constant GTK.SHADOW_OUT
constant GTK.SHRINK
constant GTK.SIDE_BOTTOM
constant GTK.SIDE_LEFT
constant GTK.SIDE_RIGHT
constant GTK.SIDE_TOP
constant GTK.SORT_ASCENDING
constant GTK.SORT_DESCENDING
constant GTK.SPIN_END
constant GTK.SPIN_HOME
constant GTK.SPIN_PAGE_BACKWARD
constant GTK.SPIN_PAGE_FORWARD
constant GTK.SPIN_STEP_BACKWARD
constant GTK.SPIN_STEP_FORWARD
constant GTK.SPIN_USER_DEFINED
constant GTK.STATE_ACTIVE
constant GTK.STATE_INSENSITIVE
constant GTK.STATE_NORMAL
constant GTK.STATE_PRELIGHT
constant GTK.STATE_SELECTED
constant GTK.TOOLBAR_BOTH
constant GTK.TOOLBAR_ICONS
constant GTK.TOOLBAR_TEXT
constant GTK.TOPLEVEL
constant GTK.TOP_BOTTOM
constant GTK.TREE_VIEW_ITEM
constant GTK.TREE_VIEW_LINE
constant GTK.TROUGH_END
constant GTK.TROUGH_JUMP
constant GTK.TROUGH_NONE
constant GTK.TROUGH_START
constant GTK.UPDATE_ALWAYS
constant GTK.UPDATE_CONTINUOUS
constant GTK.UPDATE_DELAYED
constant GTK.UPDATE_DISCONTINUOUS
constant GTK.UPDATE_IF_VALID
constant GTK.VISIBILITY_FULL
constant GTK.VISIBILITY_NONE
constant GTK.VISIBILITY_PARTIAL
constant GTK.VISIBLE
constant GTK.WINDOW_DIALOG
constant GTK.WINDOW_POPUP
constant GTK.WINDOW_TOPLEVEL
constant GTK.WIN_POS_CENTER
constant GTK.WIN_POS_MOUSE
constant GTK.WIN_POS_NONE
constant GTK.TRUE
void applet_widget_gtk_main()
Special corba main loop for gnome panel applets
void applet_widget_gtk_main_quit()
Exit from the applet_widget_gtk_main function on the next iteration.
int false()
Always returns false.
void flush()
Flush GDK. Not normally needed, can be useful while doing calculations.
array gnome_init(string app_id, string app_version, array argv, int|void corba_init_flags)
Initializes the application. This sets up all of the GNOME internals and prepares them (imlib, gdk/gtk, session-management, triggers, sound, user preferences). If corba init flags are specified, corba initialization is done as well as gnome initialization. corba_init_flags is 0 or more of GNORBA_INIT_SERVER_FUNC (1), GNORBA_INIT_DISABLE_COOKIES (2) and GNORBA_INIT_CORBA_PRIO_HIGH (4)
void grab_add(GTK.Widget widget)
void grab_remove(GTK.Widget widget)
array gtk_init(array|void argc, int|void no_pgtkrc)
Low level GTK init function (used by setup_gtk). This function is more or less equivalent to the C-GTK+ function gtk_init. setup_gtk does some extra things (such as parsing ~/.pgtkrc).
void low_flush()
Flush, but do not process events. Not normally needed.
void main()
Start GTK in blocking mode. Doing this disables asynchronous I/O in pike. You can return -1 from main in pike to run GTK (and the rest of pike) in asynchrounous mode.
int main_iteration_do(int block)
Run one iteration in the mainloop. If block is true, wait for an event before returning.
int main_level()
Return the current recursion depth.
void main_quit()
Exit from the gtk_main function on the next iteration.
void parse_rc(string rc)
Takes a string and reads it as a gtkrc file.
GDK.Window root_window()
Returns the root window of the current display
int set_new_signal_convention(int n)
array setup_gtk(array|void argv, int|void do_not_parse_rc)
Initialize GTK, and all that comes with it. Also parses $HOME/.pgtkrc and $HOME/.gtkrc if they exists. The single argument, if supplied, is the argument array passed to the program. This is used to set default window titles etc. The second argument, if supplied, indicates that pike specific *rc files should not be parsed.
The most common usage is GTK.setup_gtk(argv);
int true()
Always returns true.
| CLASS GTK.Ruler |
Ruler widgets are used to indicate the location of the mouse pointer in a given window. A window can have a vertical ruler spanning across the width and a horizontal ruler spanning down the height. A small triangular indicator on the ruler shows the exact location of the pointer relative to the ruler.
inherit GTK.Widget : Widget
GTK.Ruler draw_pos()
draw the position
GTK.Ruler draw_ticks()
draw the ticks
float get_lower()
The currently defined lower extent of the ruler.
float get_max_size()
The currently defined max_size of the ruler.
float get_position()
The currently defined initial position of the pointer indicator within the ruler.
float get_upper()
The currently defined upper extent of the ruler.
GTK.Ruler set_metric(int unit)
Either GTK.Pixels, GTK.Centimers or GTK.Inches. The default measure is GTK.Pixels.
GTK.Ruler set_range(float lower, float upper, float position, float max_size)
The lower and upper arguments define the extent of the ruler, and max_size is the largest possible number that will be displayed. Position defines the initial position of the pointer indicator within the ruler.
| CLASS GTK.Window |
The basic window. Nothing much to say about it. It can only contain one child widget. Show the main window last to avoid annoying flashes when the subwidget (and it's subwidgets) are added to it, this is done automatically by calling 'window->show_all' when you are done with your widget packing.
Signals: move_resize
set_focus
inherit GTK.Bin : Bin
int activate_default()
Activate the default widget
int activate_focus()
Activate the focus widget
GTK.Window add_accel_group(GTK.AccelGroup group)
This function adds an accelerator group to the window. The shortcuts in the table will work in the window, it's child, and all children of it's child that do not select keyboard input.
GTK.Window add_embedded_xid(int x_window_id)
Add an embedded X-window
GTK.Window GTK.Window(int window_type)
Argument is one of WINDOW_DIALOG , WINDOW_POPUP and WINDOW_TOPLEVEL
int get_allow_grow()
If true, the window can grow if nessesary
int get_allow_shrink()
If true, the window can be shrunk by the user
int get_auto_shrink()
If true, the window will shrink if possible
GTK.Widget get_default_widget()
The default widget
GTK.Widget get_focus_widget()
The focus widget
int get_modal()
If true, this is a modal dialog window
string get_title()
The title of the window
GTK.Window get_transient_parent()
The parent window for this window if this is a transient window, 0 otherwise.
int get_type()
The window type, one of WINDOW_DIALOG , WINDOW_POPUP and WINDOW_TOPLEVEL
string get_wmclass_class()
The window manager class of this application.
string get_wmclass_name()
The window manager name of this application.
GTK.Window lower()
Lower this window if the window manager allows that.
GTK.Window raise()
Raise this window if the window manager allows that.
GTK.Window remove_accel_group(GTK.AccelGroup table)
Remove a previously installed table.
GTK.Window remove_embedded_xid(int x_window_id)
Remove the embeded X window
GTK.Window set_default(GTK.Widget default_widget)
Set the default widget to the specified widget. The specified widget must have the GTK.CanDefault flag set.
GTK.Window set_default_size(int width, int height)
The following differs from set_usize, in that set_usize() overrides the requisition, and thus sets a minimum size, while this only sets the size requested from the WM.
GTK.Window set_focus(GTK.Widget child)
Set the focus widget to the specified child. Please note that this is normaly handled automatically.
GTK.Window set_icon(GDK.Pixmap p, GDK.Bitmap b, GDK.Window w)
Set the icon to the specified image (with mask) or the specified GDK.Window. It is up to the window manager to display the icon. Most window manager handles window and pixmap icons, but only a few can handle the mask argument. If you want a shaped icon, the only safe bet is a shaped window.
GTK.Window set_icon_name(string name)
Set the icon name to the specified string.
GTK.Window set_modal(int modalp)
/ Is this a modal dialog?
GTK.Window set_policy(int allow_shrink, int allow_grow, int auto_shrink)
If allow shrink is true, the user can resize the window to a smaller size. If allow_grow is true, the window can resize itself, and the user can resize the window, to a bigger size. It auto shrink is true, the window will resize itself to a smaller size when it's subwidget is resized.
GTK.Window set_position(int pos)
one of WINDOW_DIALOG , WINDOW_POPUP , WINDOW_TOPLEVEL , WIN_POS_CENTER , WIN_POS_MOUSE and WIN_POS_NONE
GTK.Window set_title(string title)
Set the window title. The default title is the value sent to setup_gtk, or if none is sent, Pike GTK.
GTK.Window set_transient_for(GTK.Window parent)
Mark this window as a transient window for the parent window. Most window managers renders transient windows differently (different borders, sometimes no resize widgets etc)
Useful for short lived dialogs.
GTK.Window set_wmclass(string name, string class)
Set the window manager application name and class.
| CLASS GTK.Hscrollbar |
A horizontal scrollbar.
General documentation: See W(Scrollbar)
GTK.Hscrollbar(GTK.Adjustment())->set_usize(300,15)
![]()
inherit GTK.Scrollbar : Scrollbar
GTK.Hscrollbar GTK.Hscrollbar(GTK.Adjustment adjustment)
Used to create a new vscale widget. The adjustment argument can either be an existing W(Adjustment), or 0, in which case one will be created for you. Specifying 0 might actually be useful in this case, if you wish to pass the newly automatically created adjustment to the constructor function of some other widget which will configure it for you, such as a text widget.
| CLASS GTK.Dialog |
A dialog is a window with a few default widgets added. The 'vbox' is the main content area of the widget. The 'action_area' is allocated for buttons (ok, cancel etc)
inherit GTK.Window : Window
GTK.Dialog GTK.Dialog()
Create a new dialog widget.
GTK.HbuttonBox get_action_area()
The action area, this is where the buttons (ok, cancel etc) go
GTK.Vbox get_vbox()
The vertical box that should contain the contents of the dialog
| CLASS GTK.Calendar |
A calendar widget.
GTK.Calendar();

GTK.Calendar()->select_day( 16 );

Signals: day_selected
day_selected_double_click
month_changed
next_month
next_year
prev_month
prev_year
inherit GTK.Widget : Widget
GTK.Calendar clear_marks()
Remove all day markers
GTK.Calendar GTK.Calendar()
Create a new calendar widget
GTK.Calendar display_options(int options)
Bitwise or of one or more of CALENDAR_NO_MONTH_CHANGE , CALENDAR_SHOW_DAY_NAMES , CALENDAR_SHOW_HEADING , CALENDAR_SHOW_WEEK_NUMBERS and CALENDAR_WEEK_START_MONDAY .
GTK.Calendar freeze()
Suspend all dynamic updating of the widget
mapping get_date()
returns a mapping: ([ "year":year, "month":month, "day":day ])
array get_day()
Return an array of 6x7 days, representing the cells in the currently viewed calendar month.
array get_day_month()
Return an array of 6x7 days, representing the cells in the currently viewed calendar month. The value is the day of month.
int get_focus_col()
The currently focused column
int get_focus_row()
The currently focused row
int get_highlight_col()
The currently highlighted column
int get_highlight_row()
The currently highlighted row
array get_marked_dates()
Returns an array (with 31 elements) with 1es and 0es.
int get_month()
The current month
int get_num_marked_dates()
The number of days that are marked
int get_selected_day()
The currently selected day
int get_year()
The current year
GTK.Calendar mark_day(int day_of_month)
Mark a day
GTK.Calendar select_day(int day_of_month)
Select a certain day of the currently selected month
int select_month(int month, int year)
Select the month to be viewed.
GTK.Calendar set_marked_date_color(int index, GDK.Color color)
Set the color to use to mark dates
GTK.Calendar thaw()
Resume dynamic updating of the widget
GTK.Calendar unmark_day(int day_of_month)
Unmark a day
| CLASS GTK.Notebook |
The NoteBook Widget is a collection of 'pages' that overlap each other, each page contains different information. This widget has become more common lately in GUI programming, and it is a good way to show blocks similar information that warrant separation in their display.
GTK.Notebook( )->set_tab_pos( GTK.POS_LEFT )->append_page( GTK.Label("Page 1\nContents"), GTK.Label("Page 1"))->append_page( GTK.Label(""), GTK.Label("Page 2"))->append_page(GTK.Label("Page 3 contents\nare here!"), GTK.Label("Page 3"))

GTK.Notebook( )->set_tab_pos( GTK.POS_TOP )->append_page( GTK.Label("Page 1\nContents"), GTK.Label("Page 1"))->append_page( GTK.Label(""), GTK.Label("Page 2"))->append_page(GTK.Label("Page 3 contents\nare here!"), GTK.Label("Page 3"))

GTK.Notebook( )->set_tab_pos( GTK.POS_RIGHT )->append_page( GTK.Label("Page 1\nContents"), GTK.Label("Page 1"))->append_page( GTK.Label(""), GTK.Label("Page 2"))->append_page(GTK.Label("Page 3 contents\nare here!"), GTK.Label("Page 3"))->next_page()->next_page()

Signals: switch_page Called when a different page is selected
inherit GTK.Container : Container
GTK.Notebook append_page(GTK.Widget contents, GTK.Widget label)
Add a new 'page' to the notebook. The first argument is the contents of the page, the second argument is the label.
GTK.Notebook append_page_menu(GTK.Widget contents, GTK.Widget label, GTK.Menu menu)
Add a new 'page' to the notebook. The first argument is the contents of the page, the second argument is the label, the third argument is a menu widget.
GTK.Notebook GTK.Notebook()
int get_current_page()
Returns the index of the currently selected page
GTK.Widget get_menu_label(GTK.Widget page)
GTK.Widget get_nth_page(int index)
Returns the page for the specified index
GTK.Widget get_tab_label(GTK.Widget page)
GTK.Notebook insert_page(GTK.Widget contents, GTK.Widget label, int pos)
Insert a page at the specified location, arguments as for append_page, but an aditional integer specifies the location.
GTK.Notebook insert_page_menu(GTK.Widget contents, GTK.Widget label, GTK.Menu menu, int pos)
Insert a page at the specified location, arguments as for append_page_menu, but an aditional integer specifies the location.
GTK.Notebook next_page()
Go to the next page
int page_num(GTK.Widget widget)
Returns the index for the specified page
GTK.Notebook popup_disable()
Disable the popup menu (set with insert_page_menu)
GTK.Notebook popup_enable()
Enable the popup menu (set with insert_page_menu)
GTK.Notebook prepend_page(GTK.Widget contents, GTK.Widget label)
Add a page at the end of the list of pages. The first argument is the contents of the page, the second argument is the label.
GTK.Notebook prepend_page_menu(GTK.Widget contents, GTK.Widget label, GTK.Menu menu)
Add a new 'page' at the end of the list of pages. The first argument is the contents of the page, the second argument is the label, the third argument is a menu widget.
GTK.Notebook prev_page()
Go to the previous page
mapping query_tab_label_packing(GTK.Widget page)
Returns ([ "expand":expandp, "fill":fillp, "pack_type":type ])
GTK.Notebook remove_page(int pos)
Remove a page.
GTK.Notebook reorder_child(GTK.Widget page, int new_index)
Move the specified page to the index new_index
GTK.Notebook set_homogeneous_tabs(int homogeneousp)
If true, all tabs will have the same size
GTK.Notebook set_menu_label(GTK.Widget page, GTK.Widget label)
GTK.Notebook set_menu_label_text(GTK.Widget page, string label)
GTK.Notebook set_page(int pos)
Go to the specified page
GTK.Notebook set_scrollable(int scrollablep)
If true, add scrollbars if nessesary.
GTK.Notebook set_show_border(int showborderp)
If true, show the borders around the contents and tabs.
GTK.Notebook set_show_tabs(int showtabsp)
If supplied with a true value, the tabs will be shown. Otherwise they will not be shown. The user will not be able to select the pages without them, but you can add 'next' and 'previous' buttons to create a wizard-line interface.
GTK.Notebook set_tab_border(int border_width)
In pixels.
GTK.Notebook set_tab_hborder(int border_width)
In pixels.
GTK.Notebook set_tab_label(GTK.Widget page, GTK.Widget label)
GTK.Notebook set_tab_label_packing(GTK.Widget child, int expand, int fill, int type)
GTK.Notebook set_tab_label_text(GTK.Widget page, string title)
GTK.Notebook set_tab_pos(int pos)
One of POS_BOTTOM , POS_LEFT , POS_RIGHT and POS_TOP
GTK.Notebook set_tab_vborder(int border_width)
In pixels.
| CLASS GTK.GammaCurve |
A gamma curve widget.. Rather complex.
Lets the user edit a gamma curve (a one-to-one mapping usually used to adjust the intensity of an image to the physical characteristics of the output device). You can set the minimum and maximum values for input and output. You can set the initial vector as well. You are guaranteed that every input value will have a (not necessarily unique) output value specified.
GTK.GammaCurve()->set_usize(210,130)

inherit GTK.Vbox : Vbox
GTK.GammaCurve GTK.GammaCurve()
Create a new gamma curve
GTK.Curve get_curve()
The actual curve
float get_gamma()
The current gamma value
| CLASS GTK.GLArea |
inherit GTK.DrawingArea : DrawingArea
GTK.GLArea GTK.GLArea(array gloptions)
GTK.GLArea make_current()
GTK.GLArea swap_buffers()
GTK.GLArea wait_gdk()
GTK.GLArea wait_gl()
| CLASS GTK.Hscale |
The GTK.HScale widget is used to allow the user to select a value using a horizontal slider. A GTK.Adjustment is used to set the initial value, the lower and upper bounds, and the step and page increments.
See W(Scale) for details
The position to show the current value, and the number of decimal places shown can be set using the parent W(Scale) class's functions.
GTK.Hscale(GTK.Adjustment())->set_usize(300,30)
![]()
inherit GTK.Scale : Scale
GTK.Hscale GTK.Hscale(GTK.Adjustment settings)
Used to create a new hscale widget. The adjustment argument can either be an existing W(Adjustment), or 0, in which case one will be created for you.
| CLASS GTK.Tooltips |
Tooltips are the messages that appear next to a widget when the mouse pointer is held over it for a short amount of time. They are especially helpful for adding more verbose descriptions of things such as buttons in a toolbar.
An individual tooltip belongs to a group of tooltips. A group is created with a call to GTK.Tooltips(). Every tooltip in the group can then be turned off with a call to disable() and enabled with enable().
The length of time the user must keep the mouse over a widget before the tip is shown, can be altered with set_delay(). This is set on a 'per group of tooltips' basis.
To assign a tip to a particular W(Widget), set_tip() is used.
The default appearance of all tooltips in a program is determined by the current gtk theme that the user has selected. To change the tooltip appearance manually, use set_colors(). Again, this is per group of tooltips.
inherit GTK.Data : Data
GTK.Tooltips GTK.Tooltips()
Creates an empty group of tooltips. This function initialises a GTK.Tooltips structure. Without at least one such structure, you can not add tips to your application.
GTK.Tooltips disable()
Disable this tooltip collection
GTK.Tooltips enable()
Enable this tooltip collection
GTK.Tooltips force_window()
Realize the tooltip window (as returned from get_gdkwindow())
GTK.Tooltips set_colors(GDK.Color foreground, GDK.Color background)
Changes the foreground and background colors.
GTK.Tooltips set_delay(int delay)
Set the delat (in seconds)
GTK.Tooltips set_tip(GTK.Widget in, string to)
Adds a tooltip containing the message tip_text to the specified W(Widget).
| CLASS GTK.Bin |
A container that can only contain one child.
inherit GTK.Container : Container
GTK.Widget get_child()
Returns the (one and only) child of this container.
| CLASS GTK.Vpaned |
The paned window widgets are useful when you want to divide an area into two parts, with the relative size of the two parts controlled by the user. A groove is drawn between the two portions with a handle that the user can drag to change the ratio. This widgets makes a vertical division
GTK.Vpaned()->add1(GTK.Label("Top Side Of Pane"))->add2(GTK.Label("Bottom"))->set_usize(100,100)

inherit GTK.Paned : Paned
GTK.Vpaned GTK.Vpaned()
| CLASS GTK.Hpaned |
The paned window widgets are useful when you want to divide an area into two parts, with the relative size of the two parts controlled by the user. A groove is drawn between the two portions with a handle that the user can drag to change the ratio. This widgets makes a horizontal division
See W(Paned) for details.
GTK.Hpaned()->add1(GTK.Label("Left\nSide\nOf\nPane"))->add2(GTK.Label("Right\nSide\nOf\nPane"))->set_usize(100,100)

inherit GTK.Paned : Paned
GTK.Hpaned GTK.Hpaned()
| CLASS GTK.Vruler |
Ruler widgets are used to indicate the location of the mouse pointer in a given window. A window can have a vertical ruler spanning across the width and a horizontal ruler spanning down the height. A small triangular indicator on the ruler shows the exact location of the pointer relative to the ruler.
GTK.Vruler()->set_metric(GTK.PIXELS)->set_range(0.0,100.0,50.0,100.0)->draw_ticks()->draw_pos()->set_usize(30,50)
![]()
GTK.Vruler()->set_metric(GTK.CENTIMETERS)->set_range(0.0,100.0,50.0,100.0)->draw_ticks()->draw_pos()->set_usize(30,50)
![]()
GTK.Vruler()->set_usize(30,50)
![]()
inherit GTK.Ruler : Ruler
GTK.Vruler GTK.Vruler()
Used to create a new vruler widget.
| CLASS GTK.Vscale |
The GTK.VScale widget is used to allow the user to select a value using a vertical slider. A GtkAdjustment is used to set the initial value, the lower and upper bounds, and the step and page increments.
The position to show the current value, and the number of decimal places shown can be set using the parent W(Scale) class's functions.
GTK.Vscale(GTK.Adjustment())->set_usize(30,100)
![]()
inherit GTK.Scale : Scale
GTK.Vscale GTK.Vscale(GTK.Adjustment settings)
Used to create a new vscale widget. The adjustment argument can either be an existing W(Adjustment), or 0, in which case one will be created for you. Specifying 0 might actually be useful in this case, if you wish to pass the newly automatically created adjustment to the constructor function of some other widget which will configure it for you, such as a text widget.
| CLASS GTK.Packer |
inherit GTK.Container : Container
GTK.Packer add(GTK.Widget widget, int side, int anchor, int options, int border_width, int pad_x, int pad_y, int i_pad_x, int i_pad_y)
side is one of SIDE_BOTTOM , SIDE_LEFT , SIDE_RIGHT and SIDE_TOP , anchor is one of ANCHOR_CENTER , ANCHOR_E , ANCHOR_EAST , ANCHOR_N , ANCHOR_NE , ANCHOR_NORTH , ANCHOR_NORTH_EAST , ANCHOR_NORTH_WEST , ANCHOR_NW , ANCHOR_S , ANCHOR_SE , ANCHOR_SOUTH , ANCHOR_SOUTH_EAST , ANCHOR_SOUTH_WEST , ANCHOR_SW , ANCHOR_W and ANCHOR_WEST , options is a bitwise or of GTK.PackExpand, GTK.FillX and GTK.FillY
GTK.Packer add_defaults(GTK.Widget widget, int side, int anchor, int options)
side is one of SIDE_BOTTOM , SIDE_LEFT , SIDE_RIGHT and SIDE_TOP , anchor is one of ANCHOR_CENTER , ANCHOR_E , ANCHOR_EAST , ANCHOR_N , ANCHOR_NE , ANCHOR_NORTH , ANCHOR_NORTH_EAST , ANCHOR_NORTH_WEST , ANCHOR_NW , ANCHOR_S , ANCHOR_SE , ANCHOR_SOUTH , ANCHOR_SOUTH_EAST , ANCHOR_SOUTH_WEST , ANCHOR_SW , ANCHOR_W and ANCHOR_WEST , options is a bitwise or of GTK.PackExpand, GTK.FillX and GTK.FillY
GTK.Packer GTK.Packer()
int get_default_border_width()
int get_default_i_pad_x()
int get_default_i_pad_y()
int get_default_pad_x()
int get_default_pad_y()
int get_spacing()
GTK.Packer reorder_child(GTK.Widget child, int pos)
GTK.Packer set_child_packing(GTK.Widget child, int side, int anchor, int options, int border_width, int pad_x, int pad_y, int i_pad_x, int i_pad_y)
side is one of SIDE_BOTTOM , SIDE_LEFT , SIDE_RIGHT and SIDE_TOP , anchor is one of ANCHOR_CENTER , ANCHOR_E , ANCHOR_EAST , ANCHOR_N , ANCHOR_NE , ANCHOR_NORTH , ANCHOR_NORTH_EAST , ANCHOR_NORTH_WEST , ANCHOR_NW , ANCHOR_S , ANCHOR_SE , ANCHOR_SOUTH , ANCHOR_SOUTH_EAST , ANCHOR_SOUTH_WEST , ANCHOR_SW , ANCHOR_W and ANCHOR_WEST , options is a bitwise or of GTK.PackExpand, GTK.FillX and GTK.FillY
GTK.Packer set_default_border_width(int border)
GTK.Packer set_default_ipad(int xpad, int ypad)
GTK.Packer set_default_pad(int xpad, int ypad)
GTK.Packer set_spacing(int new_spacing)
| CLASS GTK.Invisible |
An invisible container, useful, eh? :)
inherit GTK.Bin : Bin
GTK.Invisible GTK.Invisible()
Create a new invisible widget
| CLASS GTK.ScrolledWindow |
Scrolled windows are used to create a scrollable area with another widget inside it. You may insert any type of widget into a scrolled window, and it will be accessible regardless of the size by using the scrollbars.
GTK.ScrolledWindow(GTK.Adjustment(),GTK.Adjustment())->add(GTK.Label("A small label"))->set_usize(100,80)->set_policy(GTK.POLICY_AUTOMATIC,GTK.POLICY_AUTOMATIC)

GTK.ScrolledWindow(GTK.Adjustment(),GTK.Adjustment())->add(GTK.Label("A small label"))->set_usize(70,80)->set_policy(GTK.POLICY_AUTOMATIC,GTK.POLICY_AUTOMATIC)

GTK.ScrolledWindow(GTK.Adjustment(),GTK.Adjustment())->add(GTK.Label("A small label"))->set_usize(80,80)

GTK.ScrolledWindow(GTK.Adjustment(),GTK.Adjustment())->add(GTK.Label("A very huge label")->set_usize(700,700))->set_usize(80,80)

inherit GTK.Window : Window
GTK.ScrolledWindow add(GTK.Widget victim)
Add a widget to this container. This is equivalent to the C-GTK function gtk_scrolled_window_add_with_viewport or gtk_container_add, depeneding on whether or not the child supports the set_scroll_adjustments signal.
What this means in practice is that you do not have to care about this at all, it's all handled automatically.
GTK.ScrolledWindow GTK.ScrolledWindow(GTK.Adjustment hadjustment, GTK.Adjustment vadjustments)
The two adjustments are most commonly set to 0.
GTK.Adjustment get_hadjustment()
Return the horizontal adjustment used to scroll the window
GTK.Hscrollbar get_hscrollbar()
The horizontal scrollbar
int get_hscrollbar_policy()
One of POLICY_ALWAYS , POLICY_AUTOMATIC and POLICY_NEVER
int get_hscrollbar_visible()
1 if the horizontal scrollbar is currently visible
GTK.Adjustment get_vadjustment()
Return the vertical adjustment used to scroll the window
GTK.Vscrollbar get_vscrollbar()
The vertical scrollbar
int get_vscrollbar_policy()
One of POLICY_ALWAYS , POLICY_AUTOMATIC and POLICY_NEVER
int get_vscrollbar_visible()
1 if the vertical scrollbar is currently visible
int get_window_placement()
The location of the window relative to the scrollbars. One of CORNER_BOTTOM_LEFT , CORNER_BOTTOM_RIGHT , CORNER_TOP_LEFT and CORNER_TOP_RIGHT
GTK.ScrolledWindow set_hadjustment(GTK.Adjustment hadjustment)
Set the horizontal adjustment object
GTK.ScrolledWindow set_placement(int window_corner_placement)
The location of the window relative to the scrollbars. One of CORNER_BOTTOM_LEFT , CORNER_BOTTOM_RIGHT , CORNER_TOP_LEFT and CORNER_TOP_RIGHT
GTK.ScrolledWindow set_policy(int xpolicy, int ypolicy)
vertical and horiz policy. Both are one of POLICY_ALWAYS , POLICY_AUTOMATIC and POLICY_NEVER
GTK.ScrolledWindow set_vadjustment(GTK.Adjustment vadjustment)
Set the vertical adjustment object
| CLASS GTK.Paned |
GTK.Paned is the base class for widgets with two panes, arranged either horizontally (W(HPaned)) or vertically (W(VPaned)). Child widgets are added to the panes of the widget with pack1() and pack2(). The division beween the two children is set by default from the size requests of the children, but it can be adjusted by the user.
A paned widget draws a separator between the two child widgets and a small handle that the user can drag to adjust the division. It does not draw any relief around the children or around the separator. (The space in which the separator is called the gutter). Often, it is useful to put each child inside a W(Frame) with the shadow type set to GTK.ShadowIn so that the gutter appears as a ridge.
Each child has two options that can be set, resize and shrink. If resize is true, then when the GTK.Paned is resized, that child will expand or shrink along with the paned widget. If shrink is true, then when that child can be made smaller than it's requisition by the user. Setting shrink to 0 allows the application to set a minimum size. If resize is false for both children, then this is treated as if resize is true for both children.
The application can set the position of the slider as if it were set by the user, by calling set_position().
inherit GTK.Container : Container
GTK.Paned add1(GTK.Widget left_or_top)
Set the left or topmost item. This is equivalent to pack1(left_or_top,0,1)
GTK.Paned add2(GTK.Widget right_or_bottom)
Set the right or bottommost item This is equivalent to pack2(left_or_top,0,1)
int get_handle_size()
The size of the handle, in pixels
int get_handle_xpos()
The xpos of the handle, in pixels
int get_handle_ypos()
The ypos of the handle, in pixels
int get_in_drag()
Return 1 if the user is dragging the handle
int get_max_position()
The maximum handle position possible.
int get_min_position()
The minimum handle position possible.
GTK.Paned pack1(GTK.Widget widget, int resize, int shrink)
Add a child to the top or left pane.
GTK.Paned pack2(GTK.Widget widget, int resize, int shrink)
Add a child to the bottom or right pane.
GTK.Paned set_gutter_size(int gsize)
Set the width of the gutter. (The area between the two panes).
GTK.Paned set_handle_size(int hsize)
The size of the handle in pixels
GTK.Paned set_position(int position)
Set the position of the separator, as if set by the user. If position is negative, the remembered position is forgotten, and the division is recomputed from the the requisitions of the children.
| CLASS GTK.Arrow |
An arrow pointing in one of four directions. The 'etched' shadow
types does not work.
GTK.Arrow(GTK.ARROW_UP, GTK.SHADOW_OUT)
![]()
GTK.Arrow(GTK.ARROW_LEFT, GTK.SHADOW_IN)
![]()
GTK.Arrow(GTK.ARROW_RIGHT, GTK.SHADOW_IN)
![]()
GTK.Arrow(GTK.ARROW_DOWN, GTK.SHADOW_OUT)
![]()
inherit GTK.Misc : Misc
GTK.Arrow GTK.Arrow(int arrow_type, int shadow_type)
First argument is one of ARROW_DOWN , ARROW_LEFT , ARROW_RIGHT and ARROW_UP , second one of SHADOW_ETCHED_IN , SHADOW_ETCHED_OUT , SHADOW_IN , SHADOW_NONE and SHADOW_OUT .
int get_arrow_type()
Return the arrow type. One of ARROW_DOWN , ARROW_LEFT , ARROW_RIGHT and ARROW_UP .
int get_shadow_type()
Return the shadow type. One of SHADOW_ETCHED_IN , SHADOW_ETCHED_OUT , SHADOW_IN , SHADOW_NONE and SHADOW_OUT .
GTK.Arrow set(int arrow_type, int shadow_type)
First argument is one of ARROW_DOWN , ARROW_LEFT , ARROW_RIGHT and ARROW_UP , second one of SHADOW_ETCHED_IN , SHADOW_ETCHED_OUT , SHADOW_IN , SHADOW_NONE and SHADOW_OUT .
| CLASS GTK.MenuShell |
A GTK.MenuShell is the abstract base class used to derive the W(Menu) and W(MenuBar) subclasses.
A GTK.MenuShell is a container of W(MenuItem) objects arranged in a list which can be navigated, selected, and activated by the user to perform application functions. A W(MenuItem) can have a submenu associated with it, allowing for nested hierarchical menus.
Signals: activate_current An action signal that activates the current menu item within the menu shell.
cancel An action signal which cancels the selection within the menu shell. Causes the selection_done signal to be emitted.
deactivate This signal is emitted when a menu shell is deactivated.
move_current An action signal which moves the current menu item in the direction specified by the third argument.
selection_done This signal is emitted when a selection has been completed within a menu shell.
inherit GTK.Container : Container
GTK.MenuShell activate_item(GTK.Widget menu_item, int force_deactivate)
Activates the menu item within the menu shell.
GTK.MenuShell append(GTK.Widget what)
Adds a new W(MenuItem) to the end of the menu shell's item list. Same as 'add'.
array children()
This function returns all children of the menushell as an array.
GTK.MenuShell deactivate()
Deactivates the menu shell. Typically this results in the menu shell being erased from the screen.
int get_active()
1 if the menu shell is currently active.
GTK.MenuShell insert(GTK.Widget what, int where)
Add a widget after the specified location
GTK.MenuShell prepend(GTK.Widget what)
Add a menu item to the start of the widget (for a menu: top, for a bar: left)
GTK.MenuShell select_item(GTK.Widget menuitem)
Selects the menu item from the menu shell.
| CLASS GTK.ProgressBar |
A simple progress bar. Useful when you are doing things that take a long
time. Try to always have an 'abort' button whenever it makes sence.
GTK.ProgressBar()->update(0.1)
![]()
GTK.ProgressBar()->set_show_text(1)->update(0.3)
![]()
GTK.ProgressBar()->update(0.6)
![]()
GTK.ProgressBar()->update(1.0)
![]()
inherit GTK.Progress : Progress
GTK.ProgressBar GTK.ProgressBar()
Create a new progress bar. The default values are: Min 0.0, max 1.0, current 0.0
int get_activity_blocks()
The number of blocks that are set.
int get_activity_dir()
The current direction of the progress meter. 1 is forward and 0 is backwards. Usefull if you for some strange reason would like to know in what direction the activity indicator is swinging right now...
int get_activity_pos()
The position of the progress meter in pixels.
int get_activity_step()
The step size of the activity indicator in pixels.
int get_bar_style()
The progress bar style. GTK_PROGRESS_CONTINUOUS or GTK_PROGRESS_DISCRETE.
int get_blocks()
The total number of blocks.
int get_orientation()
The current orientation. GTK_PROGRESS_LEFT_TO_RIGHT, GTK_PROGRESS_RIGHT_TO_LEFT, GTK_PROGRESS_BOTTOM_TO_TOP or GTK_PROGRESS_TOP_TO_BOTTOM.
GTK.ProgressBar set_activity_blocks(int blocks)
The number of activity blocks
GTK.ProgressBar set_activity_step(int stepp)
Include activity blocks (empty gaps in the progressbar, ala windows 98)
GTK.ProgressBar set_bar_style(int style)
One of GTK.ProgressContinuous or GTK.ProgressDiscrete
GTK.ProgressBar set_discrete_blocks(int blocks)
The number of discrete blocks in the progress bar
GTK.ProgressBar set_orientation(int style)
One of GTK.ProgressLeftToRight, GTK.ProgressRightToLeft, GTK.ProgressBottomToTop or GTK.ProgressTopToBottom
GTK.ProgressBar update(float fraction)
0.0 is the minimum value, 1.0 is the maximum value.
| CLASS GTK.Box |
A box is a container that can contain more than one child. The basic 'Box' class cannot be instantiated, it is a virtual class that only defines some common 'Box' functions shared with all other Box widgets.
inherit GTK.Container : Container
GTK.Box pack_end(GTK.Widget widget, int expandp, int fillp, int padding)
Pack from the right (or bottom) of the box. Arguments are widget, expand, fill, paddingb widget, expand, fill, padding
GTK.Box pack_end_defaults(GTK.Widget widget)
The argument is the widget to add.
GTK.Box pack_start(GTK.Widget widget, int expandp, int fillp, int padding)
Pack from the left (or top) of the box. Argument are widget, expand, fill, padding pack(widget,1,1,0) is equivalent to 'add' or 'pack_start_defaults'
GTK.Box pack_start_defaults(GTK.Widget widget)
The argument is the widget to add. This function is equivalent to 'add'
mapping query_child_packing(GTK.Widget child)
Return a mapping: ([ "expand":expandp, "fill":fillp, "padding":paddingp, "type":type ])
GTK.Box reorder_child(GTK.Widget child, int new_position)
Move widget to pos, pos is an integer, between 0 and sizeof(box->children())-1
GTK.Box set_child_packing(GTK.Widget child_widget, int expandp, int fillp, int padding, int pack_type)
widget, expand, fill, padding, pack_type. If exand is true, the widget will be expanded when the box is resized. If 'fill' is true, the widget will be resized to fill up all available space. Padding is the amount of padding to use, and pack_type is one of PACK_END , PACK_EXPAND and PACK_START .
You can emulate pack_start and pack_end with add and set_child_packing.
GTK.Box set_homogeneous(int homogeneousp)
If true, all widgets in the box will get exactly the same amount of space
GTK.Box set_spacing(int spacing)
This is the amount of spacing (in pixels) inserted beween all widgets
| CLASS GTK.Fixed |
A fixed container is a container that keeps it's children at fixed locations and give them fixed sizes, both given in pixels.
Example:
GTK.Fixed()->put(GTK.Label("100,100"), 100, 100)->put(GTK.Label("0,0"), 0, 0)->set_usize(150,115)

inherit GTK.Container : Container
GTK.Fixed GTK.Fixed()
Create a new fixed widget
GTK.Fixed move(GTK.Widget widget, int new_xpos, int new_ypos)
Move the widget to new_xpos,new_ypos from it's old location.
GTK.Fixed put(GTK.Widget widget, int x, int y)
Place the widget at xpos,ypos.
| CLASS GTK.Item |
This class is inherited by all 'item' type of widgets.
Signals: deselect
select
toggle
inherit GTK.Bin : Bin
GTK.Item deselect()
Emulate a 'deselect' event.
GTK.Item select()
Emulate a 'select' event.
GTK.Item toggle()
Emulate a 'toggle' event.
| CLASS GTK.Range |
The category of range widgets includes the ubiquitous scrollbar widget and the less common "scale" widget. Though these two types of widgets are generally used for different purposes, they are quite similar in function and implementation. All range widgets share a set of common graphic elements, each of which has its own X window and receives events. They all contain a "trough" and a "slider" (what is sometimes called a "thumbwheel" in other GUI environments). Dragging the slider with the pointer moves it back and forth within the trough, while clicking in the trough advances the slider towards the location of the click, either completely, or by a designated amount, depending on which mouse button is used.
As mentioned in the W(Adjustment) page, all range widgets are associated with an adjustment object, from which they calculate the length of the slider and its position within the trough. When the user manipulates the slider, the range widget will change the value of the adjustment.
All of the GTK range widgets react to mouse clicks in more or less the same way. Clicking button-1 in the trough will cause its adjustment's page_increment to be added or subtracted from its value, and the slider to be moved accordingly. Clicking mouse button-2 in the trough will jump the slider to the point at which the button was clicked. Clicking any button on a scrollbar's arrows will cause its adjustment's value to change step_increment at a time.
It may take a little while to get used to, but by default, scrollbars as well as scale widgets can take the keyboard focus in GTK. If you think your users will find this too confusing, you can always disable this by unsetting the GTK.CanFocus flag on the scrollbar, like this:
scrollbar->unset_flag( GTK.CanFocus );
The key bindings (which are, of course, only active when the widget has focus) are slightly different between horizontal and vertical range widgets, for obvious reasons. They are also not quite the same for scale widgets as they are for scrollbars, for somewhat less obvious reasons (possibly to avoid confusion between the keys for horizontal and vertical scrollbars in scrolled windows, where both operate on the same area).
inherit GTK.Widget : Widget
GTK.Adjustment get_adjustment()
int get_button()
int get_click_child()
int get_digits()
int get_in_child()
int get_need_timer()
float get_old_lower()
float get_old_page_size()
float get_old_upper()
float get_old_value()
int get_policy()
int get_scroll_type()
int get_timer()
int get_x_click_point()
int get_y_click_point()
GTK.Range set_adjustment(GTK.Adjustment pos)
set_adjustment() does absolutely nothing if you pass it the adjustment that range is already using, regardless of whether you changed any of its fields or not. If you pass it a new Adjustment, it will unreference the old one if it exists (possibly destroying it), connect the appropriate signals to the new one, and call the private function gtk_range_adjustment_changed(), which will (or at least, is supposed to...) recalculate the size and/or position of the slider and redraw if necessary.
GTK.Range set_update_policy(int when)
The "update policy" of a range widget defines at what points during user interaction it will change the value field of its Adjustment and emit the "value_changed" signal on this Adjustment. The update policies are:
This is the default. The "value_changed" signal is emitted continuously, i.e., whenever the slider is moved by even the tiniest amount.
The "value_changed" signal is only emitted once the slider has stopped moving and the user has released the mouse button.
The "value_changed" signal is emitted when the user releases the mouse button, or if the slider stops moving for a short period of time.
GTK.Range slider_update()
Update the slider values.
| CLASS GTK.Hbox |
Most packing is done by creating boxes. These are invisible widget containers that we can pack our widgets into which come in two forms, a horizontal box, and a vertical box. This is the horizontal one. When packing widgets into a horizontal box, the objects are inserted horizontally from left to right or right to left depending on the call used.
GTK.Hbox(0,0)->add(GTK.Button("Hello"))->add(GTK.Button("World"))->pack_end_defaults(GTK.Button("From right"))->pack_start_defaults(GTK.Button("From left"))
![]()
GTK.Hbox(1,0)->add(GTK.Button("Hello"))->add(GTK.Button("World"))->pack_end_defaults(GTK.Button("From right"))->pack_start_defaults(GTK.Button("From left"))
![]()
GTK.Hbox(1,40)->add(GTK.Button("Hello"))->add(GTK.Button("World"))->pack_end_defaults(GTK.Button("From right"))->pack_start_defaults(GTK.Button("From left"))
![]()
inherit GTK.Box : Box
GTK.Hbox GTK.Hbox(int all_same_size, int hpadding)
Create a new horizontal box widget. If all_same_size is true, all widgets will have exactly the same size. hpadding is added to the left and right of the children.
| CLASS GTK.VbuttonBox |
A Vbutton_box is very similar to a Vbox. The major diffference is that the button box is made to pack buttons in, and has a few convenience function for normal button layouts.
GTK.VbuttonBox()->add(GTK.Button("Hello"))->add(GTK.Button("World"))->set_usize(100,300)

GTK.VbuttonBox()->add(GTK.Button("Hello"))->add(GTK.Button("World"))->set_layout(GTK.BUTTONBOX_SPREAD)->set_usize(100,300)

GTK.VbuttonBox()->add(GTK.Button("Hello"))->add(GTK.Button("World"))->set_layout(GTK.BUTTONBOX_EDGE)->set_usize(100,300)

GTK.VbuttonBox()->add(GTK.Button("Hello"))->add(GTK.Button("World"))->set_layout(GTK.BUTTONBOX_START)->set_usize(100,300)

GTK.VbuttonBox()->add(GTK.Button("Hello"))->add(GTK.Button("World"))->set_layout(GTK.BUTTONBOX_END)->set_usize(100,300)

inherit GTK.ButtonBox : ButtonBox
GTK.VbuttonBox GTK.VbuttonBox()
Create a new vertical button box
| CLASS GTK.TearoffMenuItem |
a GTK.TearoffMenuItem is a special W(MenuItem) which is used to tear off and reattach its menu.
When its menu is shown normally, the GTK.TearoffMenuItem is drawn as a dotted line indicating that the menu can be torn off. Activating it causes its menu to be torn off and displayed in its own window as a tearoff menu.
When its menu is shown as a tearoff menu, the GTK.TearoffMenuItem
is drawn as a dotted line which has a left pointing arrow graphic
indicating that the tearoff menu can be reattached. Activating it
will erase the tearoff menu window.
GTK.TearoffMenuItem()->set_usize( 100,0 )
![]()
inherit GTK.MenuItem : MenuItem
GTK.TearoffMenuItem GTK.TearoffMenuItem()
Create a new tear of menu item
int get_torn_off()
Return 1 if the menu the menu item is connected to is currently torn off.
| CLASS GTK.MenuItem |
Menu items, to be added to menues.
inherit GTK.Item : Item
GTK.MenuItem activate()
Emulate an activate signal
GTK.MenuItem configure(int toggle_indicator, int submenu_indicator)
First argument is 'show_toggle_indicator', second is 'show_submenu_indicator'.
GTK.MenuItem GTK.MenuItem(string|void label)
If a string is supplied, a W(Label) widget is created using that string and added to the item. Otherwise, you should add another widget to the list item with ->add().
GTK.MenuItem deselect()
Emulate a deselect signal
int get_accelerator_width()
The width of the accelerator string, in pixels
int get_right_justify()
Is the widget right justified?
int get_show_submenu_indicator()
Should the submenu indicator be shown?
int get_show_toggle_indicator()
Should the toggle indicator be shown?
int get_submenu_direction()
The direction the submenu will be shown in. One of DIR_DOWN , DIR_LEFT , DIR_RIGHT , DIR_TAB_BACKWARD , DIR_TAB_FORWARD and DIR_UP
int get_submenu_placement()
The placement of the submenu.
int get_toggle_size()
The size of the toggle indicator
GTK.MenuItem remove_submenu()
Remove the submenu for this menu button.
GTK.MenuItem right_justify()
Make the menu item stick to the right edge of it's container.
GTK.MenuItem select()
Emulate a select signal
GTK.MenuItem set_placement(int dir)
(sub menu placement) One of DIRECTION_LEFT and DIRECTION_RIGHT
GTK.MenuItem set_submenu(GTK.Widget menu)
Set the submenu for this menu button.
| CLASS GTK.AspectFrame |
A W(Frame) widget that always maintain a specified ratio between width and height. width/height == ratio
GTK.Aspect_frame("Title",0.5,0.5,0.4,0)->add( GTK.Label("Wrong aspect"))->set_usize(200,200)
![]()
inherit GTK.Frame : Frame
GTK.AspectFrame GTK.AspectFrame(string label, float xalign, float yalign, float ratio, int obey_child)
Create a new frame. Arguments are label, xalign, yalign, ratio, obey_child xalign is floats between 0 and 1, 0.0 is upper (or leftmost), 1.0 is lower (or rightmost). If 'obey_child' is true, the frame will use the aspect ratio of it's (one and only) child widget instead of 'ratio'.
GTK.AspectFrame set(float xalign, float yalign, float ratio, int obey_child)
Set the aspec values. Arguments are xalign, yalign, ratio, obey_child xalign is floats between 0 and 1, 0.0 is upper (or leftmost), 1.0 is lower (or rightmost). If 'obey_child' is true, the frame will use the aspect ratio of it's (one and only) child widget instead of 'ratio'.
| CLASS GTK.Scale |
The GTK.Scale widget is an abstract class, used only for deriving the subclasses GTK.Hscale and GTK.Vscale.
See W(Range) for generic range documentation
inherit GTK.Range : Range
int get_draw_value()
non-zero if the scale's current value is displayed next to the slider.
int get_value_pos()
The position in which the textual value is displayed, selected from POS_BOTTOM , POS_LEFT , POS_RIGHT and POS_TOP
int get_value_width()
An internal function used to get the maximum width needed to display the value string. Not normaly used by applications.
GTK.Scale set_digits(int precision)
Sets the number of decimal places that are displayed in the value.
GTK.Scale set_draw_value(int drawp)
Specifies whether the current value is displayed as a string next to the slider.
GTK.Scale set_value_pos(int where)
Sets the position in which the current value is displayed. One of POS_BOTTOM , POS_LEFT , POS_RIGHT and POS_TOP
| CLASS GTK.Editable |
The GTK.Editable class is a base class for widgets for editing text, such as W(Entry) and W(Text). It cannot be instantiated by itself. The editable class contains functions for generically manipulating an editable widget, a large number of action signals used for key bindings, and several signals that an application can connect to to modify the behavior of a widget.
Signals: activate Indicates that the user has activated the widget in some fashion. Generally, this will be done with a keystroke. (The default binding for this action is Return for GTK.Entry and Control-Return for GTK.Text.
changed Called when the text in the edit area is changed
copy_clipboard An action signal. Causes the characters in the current selection to be copied to the clipboard.
cut_clipboard An action signal. Causes the characters in the current selection to be copied to the clipboard and then deleted from the widget.
delete_text This signal is emitted when text is deleted from the widget by the user. The default handler for this signal will normally be responsible for inserting the text, so by connecting to this signal and then stopping the signal with signal_emit_stop(), it is possible to modify the inserted text, or prevent it from being inserted entirely. The start_pos and end_pos parameters are interpreted as for delete_text()
insert_text This signal is emitted when text is inserted into the widget by the user. The default handler for this signal will normally be responsible for inserting the text, so by connecting to this signal and then stopping the signal with signal_emit_stop(), it is possible to modify the inserted text, or prevent it from being inserted entirely.
kill_char An action signal. Delete a single character.
kill_line An action signal. Delete a single line.
kill_word n action signal. Delete a single word.
move_cursor An action signal. Move the cursor position.
move_page An action signal. Move the cursor by pages.
move_to_column An action signal. Move the cursor to the given column.
move_to_row An action signal. Move the cursor to the given row.
move_word An action signal. Move the cursor by words.
paste_clipboard An action signal. Causes the contents of the clipboard to be pasted into the editable widget at the current cursor position.
set_editable Determines if the user can edit the text in the editable widget or not. This is meant to be overriden by child classes and should not generally be useful to applications.
inherit GTK.Widget : Widget
GTK.Editable copy_clipboard()
Causes the characters in the current selection to be copied to the clipboard.
GTK.Editable cut_clipboard()
Causes the characters in the current selection to be copied to the clipboard and then deleted from the widget.
GTK.Editable delete_selection()
Deletes the current contents of the widgets selection and disclaims the selection.
GTK.Editable delete_text(int start_pos, int end_pos)
Delete a sequence of characters. The characters that are deleted are those characters at positions from start_pos up to, but not including end_pos. If end_pos is negative, then the the characters deleted will be those characters from start_pos to the end of the text.
string get_chars(int start_pos, int end_pos)
Retrieves a sequence of characters. The characters that are retrieved are those characters at positions from start_pos up to, but not including end_pos. If end_pos is negative, then the the characters retrieved will be those characters from start_pos to the end of the text.
int get_position()
Returns the cursor position
GTK.Editable insert_text(string text, int num_chars, int where)
Insert 'num_chars' characters from the text at the position 'where'.
GTK.Editable paste_clipboard()
Causes the contents of the clipboard to be pasted into the given widget at the current cursor position.
GTK.Editable select_region(int start_pos, int end_pos)
Selects a region of text. The characters that are selected are those characters at positions from start_pos up to, but not including end_pos. If end_pos is negative, then the the characters selected will be those characters from start_pos to the end of the text. are
GTK.Editable set_editable(int editablep)
Determines if the user can edit the text in the editable widget or not.
GTK.Editable set_position(int pos)
Sets the cursor position.
| CLASS GTK.Hruler |
Ruler widgets are used to indicate the location of the mouse pointer in a given window. A window can have a vertical ruler spanning across the width and a horizontal ruler spanning down the height. A small triangular indicator on the ruler shows the exact location of the pointer relative to the ruler.
GTK.Hruler()->set_metric(GTK.PIXELS)->set_range(0.0,100.0,50.0,100.0)->draw_ticks()->draw_pos()->set_usize(300,30)
![]()
GTK.Hruler()->set_metric(GTK.CENTIMETERS)->set_range(0.0,100.0,50.0,100.0)->draw_ticks()->draw_pos()->set_usize(300,30)
![]()
GTK.Hruler()->set_usize(300,30)
![]()
inherit GTK.Ruler : Ruler
GTK.Hruler GTK.Hruler()
Used to create a new hruler widget.
| CLASS GTK.InputDialog |
This dialog is used to enable XInput devices. By default, no extension devices are enabled. We need a mechanism to allow users to enable and configure their extension devices. GTK provides the InputDialog widget to automate this process. The following procedure manages an InputDialog widget. It creates the dialog if it isn't present, and shows it otherwise.
GTK.InputDialog inputd;
void create_input_dialog ()
{
if (!inputd)
{
inputd = GTK.InputDialog();
inputd->close_button()->signal_connect("clicked",inputd->hide, 0);
inputd->save_button()->hide();
inputd->show();
}
else
inputd->show();
}
GTK.InputDialog()

Signals: disable_device his signal is emitted when the user changes the mode of a device from a GDK_MODE_SCREEN or GDK_MODE_WINDOW to GDK_MODE_ENABLED
enable_device This signal is emitted when the user changes the mode of a device from GDK_MODE_DISABLED to a GDK_MODE_SCREEN or GDK_MODE_WINDOW.
inherit GTK.Dialog : Dialog
GTK.InputDialog GTK.InputDialog()
Create a new input dialog window.
GTK.Button get_close_button()
The 'close' button of the dialog.
GTK.Button get_save_button()
The 'save' button of the dialog.
| CLASS GTK.SelectionData |
The data associated with a selection.
string data()
Returns the selection in the data. The return value is always a string, but the width can vary (8, 16 or 32 bits per character).
int format()
Returns the selction format. The format is the number of bits per character.
int length()
Return the size of the selection data, in bytes.
The size of the data in characters (as returned by data()) is not necessarily the same.
GDK.Atom selection()
The selection id, as a GDK(Atom).
GTK.SelectionData set(string data)
Store new data into a GtkSelectionData object. Should _only_ by called from a selection handler callback.
GDK.Atom target()
The target, as a GDK(Atom).
GDK.Atom type()
The selection type, as a GDK(Atom).
| CLASS GTK.SpinButton |
The Spin Button widget is generally used to allow the user to select a value from a range of numeric values. It consists of a text entry box with up and down arrow buttons attached to the side. Selecting one of the buttons causes the value to "spin" up and down the range of possible values. The entry box may also be edited directly to enter a specific value.
The Spin Button allows the value to have zero or a number of decimal places and to be incremented/decremented in configurable steps. The action of holding down one of the buttons optionally results in an acceleration of change in the value according to how long it is depressed.
The Spin Button uses an W(Adjustment) object to hold information about the range of values that the spin button can take.
The attributes of an W(Adjustment) are used by the Spin Button in the following way: <ul><li>value: initial value for the Spin Button</li> <li>lower: lower range value</li> <li>upper: upper range value</li> <li>step_increment: value to increment/decrement when pressing mouse button 1 on a button</li> <li>page_increment: value to increment/decrement when pressing mouse button 2 on a button</li> <li>page_size: unused</li> </ul>
The argument order for the W(Adjustment) constructor is: value, lower, upper, step_increment, page_increment, page_size
GTK.SpinButton( GTK.Adjustment(),0.1, 1 )->set_usize(60,20)
![]()
inherit GTK.Entry : Entry
GTK.SpinButton configure(GTK.Adjustment range, float climb_rate, int precision)
Adjustment (with the lower/upper/increse values), climb_rate and digits
GTK.SpinButton GTK.SpinButton(GTK.Adjustment range, float climb_rate, int precision)
The climb_rate argument take a value between 0.0 and 1.0 and indicates the amount of acceleration that the Spin Button has. The digits argument specifies the number of decimal places to which the value will be displayed.
float get_climb_rate()
The amount of acceleration that the Spin Button has. 0.0 is no accelleration and 1.0 is highest accelleration.
int get_digits()
The number of decimal places to which the value will be displayed.
int get_numeric()
If != 0 the user can not enter anything but numeric values.
int get_snap_to_ticks()
If != 0 the Spin Button will round the value to the nearest step_increment.
int get_update_policy()
The update policy. GTK_UPDATE_ALWAYS or GTK_UPDATE_IF_VALID.
float get_value_as_float()
The current value of a Spin Button can be retrieved as a float.
int get_value_as_int()
The current value of a Spin Button can be retrieved as a int.
int get_wrap()
If != 0 the Spin Button will wrap around between the upper and lower range values.
GTK.SpinButton set_adjustment(GTK.Adjustment range)
Set a new adjustment.
GTK.SpinButton set_digits(int precision)
Set the number of digits to show to the user.
GTK.SpinButton set_numeric(int numericp)
If true, it is a numeric value. This prevents a user from typing anything other than numeric values into the text box of a Spin Button
GTK.SpinButton set_shadow_type(int type)
Type is one of SHADOW_ETCHED_IN , SHADOW_ETCHED_OUT , SHADOW_IN , SHADOW_NONE and SHADOW_OUT
GTK.SpinButton set_snap_to_ticks(int snapp)
Set the Spin Button to round the value to the nearest step_increment, which is set within the Adjustment object used with the Spin Button
GTK.SpinButton set_update_policy(int policy)
The possible values of policy are either GTK.UpdateAlways or GTK.UpdateIfValid.
These policies affect the behavior of a Spin Button when parsing inserted text and syncing its value with the values of the Adjustment.
In the case of GTK.UpdateIfValid the Spin Button value only gets changed if the text input is a numeric value that is within the range specified by the Adjustment. Otherwise the text is reset to the current value.
In case of GTK.UpdateAlways errors are ignored while converting text into a numeric value.
GTK.SpinButton set_value(float to)
Set the value.
GTK.SpinButton set_wrap(int wrapp)
If true, the spin button will wrap from the lowest to the highest value, and the highest to the lowest.
GTK.SpinButton spin(int direction, float increment)
If you want to alter the value of a Spin Value relative to its current value, then this ffunction can be used.
The direction paramenter is one of SPIN_END , SPIN_HOME , SPIN_PAGE_BACKWARD , SPIN_PAGE_FORWARD , SPIN_STEP_BACKWARD , SPIN_STEP_FORWARD and SPIN_USER_DEFINED
GTK.SpinStepForward and GTK.SpinStepBackward change the value of the Spin Button by the amount specified by increment, unless increment is equal to 0, in which case the value is changed by the value of step_increment in theAdjustment.
GTK.SpinPageForward and GTK.SpinPageBackward simply alter the value of the Spin Button by increment.
GTK.SpinHome sets the value of the Spin Button to the bottom of the Adjustments range.
GTK.SpinEnd sets the value of the Spin Button to the top of the Adjustments range.
GTK.SpinUserDefined simply alters the value of the Spin Button by the specified amount.
GTK.SpinButton update()
Explicitly request that the Spin Button updates itself
| CLASS GTK.MenuBar |
Basically a horizontal W(Menu).
The menu image cannot be
grabbed automatically, but this is how you would create a menu all
in one line. This is not the recommended coding style.
GTK.MenuBar()->add(GTK.Menu_item("Menu")->set_submenu(GTK.Menu()->add(GTK.Menu_item("Sub")))->select()->activate())->add(GTK.Menu_item("Bar"))
![]()
inherit GTK.MenuShell : MenuShell
GTK.MenuBar append(GTK.Widget menu)
GTK.MenuBar GTK.MenuBar()
GTK.MenuBar insert(GTK.Widget menu, int position)
GTK.MenuBar prepend(GTK.Widget menu)
GTK.MenuBar set_shadow_type(int int)
| CLASS GTK.Text |
The Text widget allows multiple lines of text to be displayed and edited. It supports both multi-colored and multi-font text, allowing them to be mixed in any way we wish. It also has a wide set of key based text editing commands, which are compatible with Emacs.
The text widget supports full cut-and-paste facilities, including the use of double- and triple-click to select a word and a whole line, respectively.
Bugs:<ul> <li> You cannot add text to the widget before it is realized.</li> </ul>
GTK.Text(GTK.Adjustment(),GTK.Adjustment())

function_object(call_out(GTK.Text(GTK.Adjustment(),GTK.Adjustment())->set_text, 0, "Some text")[0])

function_object(call_out(GTK.Text(GTK.Adjustment(),GTK.Adjustment())->insert, 0, "Some text", 0, GDK.Color(255,255,0), GDK.Color(0,0,0))[0])

inherit GTK.Editable : Editable
GTK.Text backward_delete(int nchars)
Delete n characters backwards from the cursor position
GTK.Text GTK.Text(GTK.Adjustment xadjustment, GTK.Adjustment yadjustment)
Creates a new GTK.Text widget, initialized with the given Gtk.Adjustments. These pointers can be used to track the viewing position of the GTK.Text widget. Passing NULL to either or both of them will make the text widget create it's own. You can set these later with the function gtk_text_set_adjustment()
GTK.Text forward_delete(int nchars)
Delete n characters forward from the cursor position
GTK.Text freeze()
Freezes the widget which disallows redrawing of the widget until it is thawed. This is useful if a large number of changes are going to made to the text within the widget, reducing the amount of flicker seen by the user.
int get_length()
Returns the length of the all the text contained within the widget
int get_point()
Gets the current position of the cursor as the number of characters from the upper left corner of the GtkText widget.
string get_text()
Get the current contents of the text object.
GTK.Text insert(string text, GDK.Font font, GDK.Color bg, GDK.Color fg)
syntax: object insert(string what); OR object insert(string what, GDK.Font font, GDK.Color fg, GDK.Color bg); OR object insert(string what, 0, GDK.Color fg, GDK.Color bg); OR object insert(string what, 0, GDK.Color fg); OR object insert(string what, 0, 0, GDK.Color bg);
Insert new text, optionally with colors.
GTK.Text set_adjustments(GTK.Adjustment xadjustment, GTK.Adjustment yadjustment)
Change the adjustments (as supplied to the constructor) to other adjustments.
GTK.Text set_editable(int editablep)
If true, the user can change the text in the widget.
GTK.Text set_line_wrap(int linewrapp)
If true, the widget will automatically wrap the contents.
GTK.Text set_point(int point)
Sets the cursor at the given point. In this case a point constitutes the number of characters from the extreme upper left corner of the widget.
GTK.Text set_text(string to)
Set the text to the specified string.
GTK.Text set_word_wrap(int wordwrapp)
If true, the widget will automatically wrap the contents.
GTK.Text thaw()
unfreeze the widget.
| CLASS GTK.Curve |
GTK.Curve()
![]()
inherit GTK.DrawingArea : DrawingArea
GTK.Curve GTK.Curve()
array get_vector(int num_points)
GTK.Curve reset()
GTK.Curve set_curve_type(int type)
One of CURVE_TYPE_FREE , CURVE_TYPE_LINEAR and CURVE_TYPE_SPLINE ;
GTK.Curve set_gamma(float gamma)
GTK.Curve set_range(float min_x, float max_x, float min_y, float max_y)
GTK.Curve set_vector(int nelems, array curve)
| CLASS GTK.RadioMenuItem |
Exactly like W(RadioButton), but it is an menu item.
GTK.RadioMenuItem("Menu item")
![]()
inherit GTK.MenuItem : MenuItem
GTK.RadioMenuItem GTK.RadioMenuItem(string|void title, GTK.RadioMenuItem groupmember)
object GTK.RadioMenuItem(string title) - First button (with label) object GTK.RadioMenuItem()->add(widget) - First button (with widget) object GTK.RadioMenuItem(title, another_radio_button) - Second to n:th button (with title) object GTK.RadioMenuItem(0,another_radio_button)->add(widget) - Second to n:th button (with widget)
GTK.RadioMenuItem set_group(GTK.RadioMenuItem groupmember)
the argument is another radio menu item to whose group this button should be added to. It is prefereable to use the second argument to the constructor instead, but if you for some reason want to move the button to another group, use this function.
| CLASS GTK.Label |
A simple text label.
GTK.Label("A simple text label")
![]()
GTK.Label("Multi\nline text\nlabel here")
![]()
GTK.Label("Multi\nline text\nlabel here")->set_justify(GTK.JUSTIFY_LEFT)
![]()
GTK.Label("Multi\nline text\nlabel here")->set_justify(GTK.JUSTIFY_RIGHT)
![]()
inherit GTK.Misc : Misc
GTK.Label GTK.Label(string text)
Creates a new label.
int parse_uline(string uline_string)
Convenience function to set the text and pattern by parsing a string with embedded underscores, returns the appropriate key symbol for the accelerator.
GTK.Label set(string text)
DEPRECATED Compatibility function to set the text in the label. Use set_text. This function can dissapear in the future.
GTK.Label set_justify(int justify)
one of JUSTIFY_CENTER , JUSTIFY_FILL , JUSTIFY_LEFT and JUSTIFY_RIGHT
GTK.Label set_line_wrap(int wrapp)
Should the label autolinewrap?
GTK.Label set_pattern(string pattern_string)
A string with either spaces or underscores. It should be of the same length as the text.
When a character in the text has a matching _ in the pattern, the character in the label will be underlined.
GTK.Label set_text(string text)
Set the text in the label
| CLASS GTK.HandleBox |
The contents of a handle box can be 'dragged' out of the box by the user.
The contents will then be placed in a separate window.
GTK.HandleBox()->add(GTK.Label("The contents"))
![]()
Signals: child_attached Called when a new child is added to the box
child_detached Called when a child is removed from the box
inherit GTK.Bin : Bin
GTK.HandleBox GTK.HandleBox()
Create a new handle box widget.
int get_child_detached()
Is the child detatched?
int get_float_window_mapped()
Is the floating window mapped?
int get_handle_position()
The position of the handle. One of POS_BOTTOM , POS_LEFT , POS_RIGHT and POS_TOP
int get_in_drag()
1 if the window is beeing dragged around right now.
int get_shrink_on_detach()
True if the container should shrink when the child is detatched
int get_snap_edge()
The edge to snap to. One of POS_BOTTOM , POS_LEFT , POS_RIGHT and POS_TOP , or -1 for unset.
GTK.HandleBox set_handle_position(int pos)
The position of the handle. One of POS_BOTTOM , POS_LEFT , POS_RIGHT and POS_TOP
int set_set_shrink_on_detach()
True if the container should shrink when the child is detatched
GTK.HandleBox set_shadow_type(int shadow_type)
One of SHADOW_ETCHED_IN , SHADOW_ETCHED_OUT , SHADOW_IN , SHADOW_NONE and SHADOW_OUT
GTK.HandleBox set_snap_edge(int pos)
The edge to snap to. One of POS_BOTTOM , POS_LEFT , POS_RIGHT and POS_TOP , or -1 for unset.
| CLASS GTK.AccelLabel |
A label for accelerators.
inherit GTK.Label : Label
GTK.AccelLabel GTK.AccelLabel(string text)
int get_accel_width()
int refetch()
GTK.AccelLabel set_accel_widget(GTK.Widget accel_widget)
| CLASS GTK.Viewport |
This is a container that can be scrolled around, but it has no scrollbars.
You can connect scrollbars to it using the adjustment objects.
GTK.Viewport(GTK.Adjustment(),GTK.Adjustment())->set_usize(100,100)

GTK.Viewport(GTK.Adjustment(),GTK.Adjustment())->set_usize(100,100)->set_shadow_type(GTK.SHADOW_ETCHED_IN)

GTK.Viewport(GTK.Adjustment(),GTK.Adjustment())->set_usize(100,100)->add(GTK.Label("A label with a very long text on it, it will not fit"))->set_shadow_type(GTK.SHADOW_ETCHED_IN)

lambda(){ object a1;object v = GTK.Viewport(a1=GTK.Adjustment(),GTK.Adjustment())->set_usize(100,100)->add(GTK.Label("A label with a very long text on it, it will not fit"))->set_shadow_type(GTK.SHADOW_ETCHED_IN);call_out(a1->set_value,0,100.0);return v;}()

inherit GTK.Bin : Bin
GTK.Viewport GTK.Viewport(GTK.Adjustment xscroll, GTK.Adjustment yscroll)
Create a new viewport. The adjustments are used to select what part of the viewport to view to the user. They are normally connected to a scrollbar or something similar.
GTK.Adjustment get_hadjustment()
Return the current horizontal adjustment object
GTK.Adjustment get_vadjustment()
Return the current vertical adjustment object
GTK.Viewport set_hadjustment(GTK.Adjustment xscroll)
Set a new horizontal adjustment object.
GTK.Viewport set_shadow_type(int type)
Set the shadow style. One of SHADOW_ETCHED_IN , SHADOW_ETCHED_OUT , SHADOW_IN , SHADOW_NONE and SHADOW_OUT
GTK.Viewport set_vadjustment(GTK.Adjustment yscroll)
Set a new vertical adjustment object.
| CLASS GTK.Menu |
A GTK.Menu is a W(MenuShell) that implements a drop down menu consisting of a list of W(MenuItem) objects which can be navigated and activated by the user to perform application functions.
A GTK.Menu is most commonly dropped down by activating a W(MenuItem) in a W(MenuBar) or popped up by activating a W(MenuItem) in another GTK.Menu.
A GTK.Menu can also be popped up by activating a W(OptionMenu). Other composite widgets such as the W(Notebook) can pop up a GTK.Menu as well.
Applications can display a GTK.Menu as a popup menu by calling the popup() function. The example below shows how an application can pop up a menu when the 3rd mouse button is pressed.
GTK.Menu menu = create_menu();
GTK.Window window = create_window();
window->signal_connect( "button_press_event", lambda(GTK.Menu m,
GTK.Window w,
mapping e ) {
if( e->button == 3 )
menu->popup();
}, menu );
inherit GTK.MenuShell : MenuShell
GTK.Menu append(GTK.Widget widget)
Adds a new W(MenuItem) to the end of the menu's item list.
GTK.Menu attach_to_widget(GTK.Widget widget)
Attach the menu to a widget
GTK.Menu GTK.Menu()
Create a new GTK.Menu widget.
GTK.Menu detach()
Detaches the menu from the widget to which it had been attached.
GTK.Widget get_active()
Returns the selected menu item from the menu. This is used by the W(OptionMenu).
GTK.Widget get_attach_widget()
Returns the W(Widget) that the menu is attached to.
int get_torn_off()
return 1 if the menu is torn off.
GTK.Menu insert(GTK.Widget widget, int position)
Adds a new W(MenuItem) to the menu's item list at the position indicated by position.
GTK.Menu popdown()
Removes the menu from the screen.
GTK.Menu popup(int|void button_pressed_to_show_menu)
The default button is 3.
GTK.Menu prepend(GTK.Widget widget)
Adds a new W(MenuItem) to the start of the menu's item list.
GTK.Menu reorder_child(GTK.Widget menuitem, int pos)
Moves a W(MenuItem) to a new position within the GTK.Menu.
GTK.Menu reposition()
Repositions the menu according to its position function.
GTK.Menu set_accel_group(GTK.AccelGroup accelerators)
Set the W(AccelGroup) which holds global accelerators for the menu.
GTK.Menu set_active(int activep)
Selects the specified menu item within the menu. This is used by the W(OptionMenu).
GTK.Menu set_tearoff_state(int torn_off)
Changes the tearoff state of the menu. A menu is normally displayed as drop down menu which persists as long as the menu is active. It can also be displayed as a tearoff menu which persists until it is closed or reattached.
GTK.Menu set_title(string new_title)
Sets the title string for the menu. The title is displayed when the menu is shown as a tearoff menu.
| CLASS GTK.Dial |
This widget provides an analog dial widget, similar to, for
example, a physical volume control on a stereo. Dial values can be
changable or read-only for value reporting.
GTK.Dial( GTK.Adjustment() );

GTK.Dial( GTK.Adjustment(10.0) )->set_percentage(0.4);

inherit GTK.Widget : Widget
GTK.Dial GTK.Dial(GTK.Adjustment adjustment)
GTK.Adjustment get_adjustment()
float get_percentage()
Retrieves the current percentage held in the dial widget.
float get_value()
Retrieves the current value helt in the dial widget.
GTK.Dial set_adjustment(GTK.Adjustment pos)
set_adjustment() does absolutely nothing if you pass it the adjustment that range is already using, regardless of whether you changed any of its fields or not. If you pass it a new Adjustment, it will unreference the old one if it exists (possibly destroying it), connect the appropriate signals to the new one, and call the private function gtk_range_adjustment_changed(), which will (or at least, is supposed to...) recalculate the size and/or position of the slider and redraw if necessary.
GTK.Dial set_percentage(float percent)
Sets the GTK.Dial's value to percent of dial->adjustment->upper. The upper value is set when the GtkAdjustment is created.
GTK.Dial set_update_policy(int when)
The "update policy" of a range widget defines at what points during user interaction it will change the value field of its Adjustment and emit the "value_changed" signal on this Adjustment. The update policies are:
This is the default. The "value_changed" signal is emitted continuously, i.e., whenever the slider is moved by even the tiniest amount.
The "value_changed" signal is only emitted once the slider has stopped moving and the user has released the mouse button.
The "value_changed" signal is emitted when the user releases the mouse button, or if the slider stops moving for a short period of time.
float set_value(float to)
Sets the current value held in the GtkDial's adjustment object to value. Returns the new percentage of value to the adjustment's upper limit.
GTK.Dial set_view_only(int view_only)
Specifies whether or not the user is to be able to edit the value represented by the dial widget. If view_only is TRUE, the dial will be set to view-only mode, and the user will not be able to edit it. If view_only is FALSE, the user will be able to change the valuerepresented.
| CLASS GTK.Statusbar |
Statusbars are simple widgets used to display a text message. They keep a stack of the messages pushed onto them, so that popping the current message will re-display the previous text message.
In order to allow different parts of an application to use the same statusbar to display messages, the statusbar widget issues Context Identifiers which are used to identify different 'users'. The message on top of the stack is the one displayed, no matter what context it is in. Messages are stacked in last-in-first-out order, not context identifier order.
lambda() {object sb = GTK.Statusbar();int id = sb->get_context_id("test");sb->push(id,"A message");sb->push(id,"Another message");return sb;}()
![]()
lambda() {object sb = GTK.Statusbar();int id = sb->get_context_id("test");sb->push(id,"A message");sb->push(id,"Another message");sb->pop(id);return sb;}()
![]()
Signals: text_poped
text_pushed
inherit GTK.Hbox : Hbox
GTK.Statusbar GTK.Statusbar()
Create a new statusbar widget
int get_context_id(string context)
Create a new context id (or get the id of an old one). The argument is any string. The return value can be used for ->push() ->pop() and ->remove later on.
GTK.Statusbar pop(int context)
Remove the topmost message.
int push(int context, string data)
Push a message onto the statusbar. The return value is an id that can be passed to remove later on.
GTK.Statusbar remove(int context, int id)
Remove the specified message (the message id is the second argument).
| CLASS GTK.Image |
An image is a image object stored in client, not X server, memory. A pixmap, on the other hand, is a image object stored in the X-server. See GDK.Image and GDK.Pixmap.
GTK.Image( GDK.Image(0)->set(Image.Image(200,200)->test() ) );

inherit GTK.Misc : Misc
GTK.Image GTK.Image(GDK.Image image, GDK.Bitmap mask)
You can skip the mask. The mask is used to mask the drawing of the image on it's background. It will not make the container transparent, though. Use shape_combine_mask on the container with the mask for that.
mapping get()
Returns ([ "image":GDK.Image img, "mask":GDK.Bitmap mask ])
GTK.Image set(GDK.Image image, GDK.Bitmap mask)
Args: GDK.Image and GDK.Bitmap, respectively. You can skip the mask. The mask is used to mask the drawing of the image on it's background. It will not make the container transparent, though. Use shape_combine_mask on the container with the mask for that.
There is no need to call 'set' with the same GDK.Image again if you have modified the image. You must, however, use ->queue_draw() to redraw the image. Otherwise the old contens will be shown until an refresh of the widget is done for any other reason.
| CLASS GTK.Object |
The basic GTK class. All other GTK classes inherit this class. The only user-callable functions are the signal related ones.
Signals: destroy Called when the object is destroyed
GTK.Object destroy()
GTK.Object signal_block(mixed signal_id)
Temporarily block a signal handler. No signals will be received while the hander is blocked. See signal connect for more info.
mixed signal_connect(string signal, function callback, mixed|void callback_arg)
Connect a signal to a pike function. The function will be called with the last argument to this function as it's first argument (defaults to 0), the second argument is always the widget, any other arguments are the ones supplied by GTK.
The return value of this function can be used to remove a signal with signal_disconnect, and block and unblock the signal will signal_block and signal_unblock.
mixed signal_connect_new(string signal, function callback, mixed|void callback_arg)
Connect a signal to a pike function.
This function differs from the signal_connect function in how it calls the callback function.
The old interface:
void signal_handler( mixed my_arg, GTK.Object object,
mixed ... signal_arguments )
The new interface:
void signal_handler( mixed ... signal_arguments,
mixed my_arg, GTK.Object object )
The return value of this function can be used to remove a signal with signal_disconnect, and block and unblock the signal will signal_block and signal_unblock.
GTK.Object signal_disconnect(mixed signal_id)
Remove a signal formerly added by signal_connect. The argument is the return value of signal_connect(). See signal connect for more info.
GTK.Object signal_emit(string signal_name)
Halt the emit of the current named signal. Useful in signal handlers when you want to override the behaviour of some default signal handler (key press events, as an example) See signal_connect.
GTK.Object signal_unblock(mixed signal_id)
Unblock a formerly blocked signal handler. See signal_block and signal_connect for more info.
| CLASS GTK.Hseparator |
Simply creates a horizontal separator. No bells or whistles.
GTK.Hseparator()->set_usize(300,3)
![]()
inherit GTK.Separator : Separator
GTK.Hseparator GTK.Hseparator()
Used to create a new hseparator widget.
| CLASS GTK.FontSelectionDialog |
The GtkFontSelectionDialog widget is a dialog box for selecting a font.
To set the font which is initially selected, use set_font_name().
To get the selected font use get_font() or get_font_name().
To change the text which is shown in the preview area, use set_preview_text().
The base filter is not yet implemented in Pike GTK.
Filters can be used to limit the fonts shown. There are 2 filters in
the GtkFontSelectionDialog - a base filter and a user filter. The
base filter can not be changed by the user, so this can be used when
the user must choose from the restricted set of fonts (e.g. for a
terminal-type application you may want to force the user to select a
fixed-width font). The user filter can be changed or reset by the
user, by using the 'Reset Filter' button or changing the options on
the 'Filter' page of the dialog.
GTK.FontSelectionDialog("Select a font")

inherit GTK.Window : Window
GTK.FontSelectionDialog GTK.FontSelectionDialog(string title)
Create a new font selection dialog with the specified window title
GTK.Button get_apply_button()
The apply button
GTK.Button get_cancel_button()
The cancel button
GTK.FontSelection get_fontsel()
The W(FontSelection) widget
GTK.Button get_ok_button()
The ok button
| CLASS GTK.Toolbar |
Toolbars are usually used to group some number of widgets in order to simplify customization of their look and layout. Typically a toolbar consists of buttons with icons, labels and tooltips, but any other widget can also be put inside a toolbar. Finally, items can be arranged horizontally or vertically and buttons can be displayed with icons, labels, or both.
Examples:
lambda(){object t=GTK.Toolbar( GTK.ORIENTATION_HORIZONTAL, GTK.TOOLBAR_TEXT );t->append_item( "Button 1", "Tooltip 1", "", GTK.Frame(), lambda(){},0);t->append_space();t->append_item( "Button 2", "Tooltip 2", "", GTK.Frame(), lambda(){},0);t->append_item( "Button 3", "Tooltip 3", "", GTK.Frame(), lambda(){},0);t->append_space();t->append_item( "Button 4", "Tooltip 4", "", GTK.Frame(), lambda(){},0);t->append_item( "Button 5", "Tooltip 5", "", GTK.Frame(), lambda(){},0);return t;}()
![]()
lambda(){object t=GTK.Toolbar( GTK.ORIENTATION_VERTICAL, GTK.TOOLBAR_TEXT );t->append_item( "Button 1", "Tooltip 1", "", GTK.Frame(), lambda(){},0);t->append_space();t->append_item( "Button 2", "Tooltip 2", "", GTK.Frame(), lambda(){},0);t->append_item( "Button 3", "Tooltip 3", "", GTK.Frame(), lambda(){},0);t->append_space();t->append_item( "Button 4", "Tooltip 4", "", GTK.Frame(), lambda(){},0);t->append_item( "Button 5", "Tooltip 5", "", GTK.Frame(), lambda(){},0);return t;}()
![]()
lambda(){object i=GDK.Image()->set(Image.Image(20,20)->test());object t=GTK.Toolbar( GTK.ORIENTATION_HORIZONTAL, GTK.TOOLBAR_BOTH );t->append_item( "Button 1", "Tooltip 1", "", GTK.Image(i), lambda(){},0);t->append_space();t->append_item( "Button 2", "Tooltip 2", "", GTK.Image(i), lambda(){},0);t->append_item( "Button 3", "Tooltip 3", "", GTK.Image(i), lambda(){},0);t->append_space();t->append_item( "Button 4", "Tooltip 4", "", GTK.Image(i), lambda(){},0);t->append_item( "Button 5", "Tooltip 5", "", GTK.Image(i), lambda(){},0);return t;}()
![]()
Signals: orientation_changed
style_changed
inherit GTK.Container : Container
GTK.Toolbar append_item(string label, string tooltip, string prv, GTK.Widget icon, function clicked_cb, mixed clicked_arg)
Adds a new button to the start of the toolbar.
GTK.Toolbar append_space()
Adds a small space.
GTK.Toolbar append_widget(GTK.Widget widget, string tootip, string prv)
Append a custom widgets. Arguments are widget, tooltip, private
GTK.Toolbar GTK.Toolbar(int orientation, int style)
Orientation is one of ORIENTATION_HORIZONTAL and ORIENTATION_VERTICAL . Style is one of TOOLBAR_BOTH , TOOLBAR_ICONS and TOOLBAR_TEXT
int get_button_relief()
GTK.Toolbar insert_item(string label, string tooltip, string prv, GTK.Widget icon, function clicked_cb, mixed clicked_arg, int position)
Arguments as for append_item, but an extra position argument at the end. Adds a new button after the item at the specified position.
GTK.Toolbar insert_space(int pixels)
Inserts a small space at the specified postion.
GTK.Toolbar insert_widget(GTK.Widget widget, string tootip, string prv, int pos)
Insert a custom widgets.
GTK.Toolbar prepend_item(string label, string tooltip, string prv, GTK.Widget icon, function clicked_cb, mixed clicked_arg)
Arguments as for append_item Adds a new button to the end of the toolbar.
GTK.Toolbar prepend_space()
Adds a small space.
GTK.Toolbar prepend_widget(GTK.Widget widget, string tootip, string prv)
Prepend a custom widgets. Arguments are widget, tooltip, private
GTK.Toolbar set_button_relief(int relief)
GTK.Toolbar set_orientation(int orientation)
Set the orientation, one of ORIENTATION_HORIZONTAL and ORIENTATION_VERTICAL
GTK.Toolbar set_space_size(int pixels)
Set the width (or height) of the space created by append_space.
GTK.Toolbar set_space_style(int style)
GTK.Toolbar set_style(int style)
Set the style, one of TOOLBAR_BOTH , TOOLBAR_ICONS and TOOLBAR_TEXT
GTK.Toolbar set_tooltips(int tootipp)
If true, show the tooltips.
| CLASS GTK.DrawingArea |
The drawing area is a window you can draw in.
Please note that you must handle refresh and resize events
on your own. Use W(pDrawingArea) for a drawingarea with automatic
refresh/resize handling.
GTK.DrawingArea()->set_usize(100,100)

inherit GTK.Widget : Widget
GTK.DrawingArea clear(int|void x, int|void y, int|void width, int|void height)
Either clears the rectangle defined by the arguments, of if no arguments are specified, the whole drawable.
GTK.DrawingArea copy_area(GDK.GC gc, int xdest, int ydest, GTK.Widget source, int xsource, int ysource, int width, int height)
Copies the rectangle defined by xsource,ysource and width,height from the source drawable, and places the results at xdest,ydest in the drawable in which this function is called.
GTK.DrawingArea GTK.DrawingArea()
GTK.DrawingArea draw_arc(GDK.GC gc, int filledp, int x1, int y1, int x2, int y2, int angle1, int angle2)
Draws a single circular or elliptical arc. Each arc is specified by a rectangle and two angles. The center of the circle or ellipse is the center of the rectangle, and the major and minor axes are specified by the width and height. Positive angles indicate counterclockwise motion, and negative angles indicate clockwise motion. If the magnitude of angle2 is greater than 360 degrees, it is truncated to 360 degrees.
GTK.DrawingArea draw_bitmap(GDK.GC gc, GDK.Bitmap bitmap, int xsrc, int ysrc, int xdest, int ydest, int width, int height)
Draw a GDK(Bitmap) in this drawable. NOTE: This drawable must be a bitmap as well. This will be fixed in GTK 1.3
GTK.DrawingArea draw_image(GDK.GC gc, GDK.Image image, int xsrc, int ysrc, int xdest, int ydest, int width, int height)
Draw the rectangle specified by xsrc,ysrc+width,height from the GDK(Image) at xdest,ydest in the destination drawable
GTK.DrawingArea draw_line(GDK.GC gc, int x1, int y1, int x2, int y2)
img_begin w = GTK.DrawingArea()->set_usize(100,100); delay: g = GDK.GC(w)->set_foreground( GDK.Color(255,0,0) ); delay: for(int x = 0; x<10; x++) w->draw_line(g,x*10,0,100-x*10,99); img_end
GTK.DrawingArea draw_pixmap(GDK.GC gc, GDK.Pixmap pixmap, int xsrc, int ysrc, int xdest, int ydest, int width, int height)
Draw the rectangle specified by xsrc,ysrc+width,height from the GDK(Pixmap) at xdest,ydest in the destination drawable
GTK.DrawingArea draw_point(GDK.GC gc, int x, int y)
img_begin w = GTK.DrawingArea()->set_usize(10,10); delay: g = GDK.GC(w)->set_foreground( GDK.Color(255,0,0) ); delay: for(int x = 0; x<10; x++) w->draw_point(g, x, x); img_end
GTK.DrawingArea draw_rectangle(GDK.GC gc, int filledp, int x1, int y1, int x2, int y2)
img_begin w = GTK.DrawingArea()->set_usize(100,100); delay: g = GDK.GC(w)->set_foreground( GDK.Color(255,0,0) ); delay: for(int x = 0; x<10; x++) w->draw_rectangle(g,0,x*10,0,100-x*10,99); img_end img_begin w = GTK.DrawingArea()->set_usize(100,100); delay: g = GDK.GC(w); delay: for(int x = 0; x<30; x++) { delay: g->set_foreground(GDK.Color(random(255),random(255),random(255)) ); delay: w->draw_rectangle(g,1,x*10,0,100-x*10,99); delay: } img_end
GTK.DrawingArea draw_text(GDK.GC gc, GDK.Font font, int x, int y, string text, int forcewide)
y is used as the baseline for the text. If forcewide is true, the string will be expanded to a wide string even if it is not already one. This is useful when writing text using either unicode or some other 16 bit font.
GTK.DrawingArea size(int width, int height)
This function is OBSOLETE
| CLASS GTK.CTreeRow |
This class is deprecated.
GTK.CTreeNode get_children()
Return the first child
int get_expanded()
Return 1 if the node is expanded
int get_is_leaf()
Return 1 if the node is a leaf node
int get_level()
Return the level of this node (0 for root, 1 for a child of the root, etc)
GTK.CTreeNode get_parent()
Return the parent node of this node
| CLASS GTK.Layout |
inherit GTK.Container : Container
GTK.Layout GTK.Layout(GTK.Adjustment hadjustment, GTK.Adjustment vadjustment)
GTK.Layout freeze()
GTK.Adjustment get_hadjustment()
int get_height()
GTK.Adjustment get_vadjustment()
int get_width()
int get_xoffset()
int get_yoffset()
GTK.Layout move(GTK.Widget widget, int x, int y)
GTK.Layout put(GTK.Widget widget, int x, int y)
GTK.Layout set_hadjustment(GTK.Adjustment adj)
GTK.Layout set_size(int xsize, int ysize)
GTK.Layout set_vadjustment(GTK.Adjustment adj)
GTK.Layout thaw()
| CLASS GTK.CTreeNode |
This is one of the nodes (branch or leaf) of the CTree. They are the equivalent of row numbers in a normal CList.
CTreeNode child()
Returns the first child node
int get_expanded()
Returns the previous sibling (the next on the same level)
int get_is_leaf()
Returns the previous sibling (the next on the same level)
int get_level()
Returns the previous sibling (the next on the same level)
CTreeNode next()
Returns the next sibling (the next on the same level)
GTK.CTreeNode parent()
Returns the parent node
CTreeNode prev()
Returns the previous sibling (the next on the same level)
GTK.CTreeRow row()
Returns the CTreeRow associated with this CTreeNode. DEPRECATED, all CTreeRow functions are also available directly in this object.
| CLASS GTK.AccelGroup |
An AccelGroup stores keybindings. A group is automatically created by W(MenuFactory)
NOIMG
inherit GTK.Data : Data
GTK.AccelGroup add_accel(GTK.Widget widget, string signal, int key, int modifiers, int flags)
the widget is the one in which the signal specified by 'signal' recides.
The key is the character code (such as 'a' for the a key and '@' for the @ key), and modifiers is a bitmap of one or more bits, the bits are . Flags is one or more of ACCEL_LOCKED , ACCEL_SIGNAL_VISIBLE and ACCEL_VISIBLE
GTK.AccelGroup GTK.AccelGroup()
Create a new accelerator group
GTK.AccelGroup destroy()
GTK.AccelGroup remove(GTK.Widget widget, int key, int modifiers)
Remove all bindings for the specified key/mask in the specified object.
| CLASS GTK.Container |
The basic container class.
Signals: add Called when a new object is added to the container. (used internally)
focus Called when the container gets focus (used internally)
need_resize Called when the container needs resizing (used internally)
remove Called when a object is removed from the container (used internally)
set_focus_child
inherit GTK.Widget : Widget
GTK.Container add(GTK.Widget widget)
Add a subwidget to the container. Don't forget to call show() in the subwidget. Some (even most) containers can only contain one child. Calling this function might result in a resize of the container.
GTK.Container border_width(int width)
Compatibility alias for set_border_width. Do not use this function in new code!
array children()
This function returns all children of the container as an array.
GTK.Container focus(int focus_direction)
Emulate a focus event. direction is one of DIR_DOWN , DIR_LEFT , DIR_RIGHT , DIR_TAB_BACKWARD , DIR_TAB_FORWARD and DIR_UP .
GTK.Container remove(GTK.Widget widget)
Remove a child from the container. The argument is the child to remove. Calling this function might result in a resize of the container.
GTK.Container set_border_width(int external_border_width)
Set the border width. The border width is the size of the padding around the container. Calling this function might result in a resize of the container.
GTK.Container set_focus_child(GTK.Widget child)
Emulate a set_focus_child signal. Focus on the specified child.
GTK.Container set_focus_hadjustment(GTK.Adjustment adj)
Set the hadjustment used to focus children.
GTK.Container set_focus_vadjustment(GTK.Adjustment adj)
Set the vadjustment used to focus children.
GTK.Container set_resize_mode(int mode)
One of RESIZE_IMMEDIATE , RESIZE_PARENT and RESIZE_QUEUE
| CLASS GTK.RadioButton |
Radio buttons are similar to check buttons except they are grouped so that only one may be selected/depressed at a time. This is good for places in your application where you need to select from a short list of options. To connect the buttons, use another button in the desired group as the second argument to GTK.RadioButton().
GTK.Radio_button("Button");
![]()
inherit GTK.CheckButton : CheckButton
GTK.RadioButton GTK.RadioButton(string|void title, GTK.RadioButton groupmember)
Normal creation: object GTK.RadioButton(string title) - First button (with label) object GTK.RadioButton()->add(widget) - First button (with widget) object GTK.RadioButton(title, another_radio_button) - Second to n:th button (with title) object GTK.RadioButton(0,another_radio_button)->add(widget) - Second to n:th button (with widget)
GTK.RadioButton set_group(GTK.RadioButton groupmember)
the argument is another radio button to whose group this button should be added to. It is prefereable to use the second argument to the constructor instead, but if you for some reason want to move the button to another group, use this function.
| CLASS GTK.Progress |
inherit GTK.Widget : Widget
GTK.Progress configure(float value, float min, float max)
Sets the current value, the minimum value and the maximum value. The default min and max are 0.0 and 1.0 respectively.
int get_activity_mode()
The currently set activity mode.
float get_current_percentage()
Returns a float between 0.0 and 1.0
string get_current_text()
Return the current text (see set_format_string)
string get_format()
The format used to convert the value to a the text
float get_percentage_from_value(float value)
Returns a float between 0.0 and 1.0
int get_show_text()
1 if the text will be shown
string get_text_from_value(float value)
Formats 'value' and returns it as a text.
float get_value()
Return the current value
float get_x_align()
The text alignment, 0.0 is leftmost, 1.0 is rightmost
float get_y_align()
The text alignment, 0.0 is topmost, 1.0 is bottommost
GTK.Progress set_activity_mode(int modep)
As well as indicating the amount of progress that has occured, the progress bar may be set to just indicate that there is some activity. This can be useful in situations where progress cannot be measured against a value range. Mode is: 1: active 0: inactive
GTK.Progress set_adjustment(GTK.Adjustment adjustment)
Sets the adjustment to use. See the adjustment documentation for more info
GTK.Progress set_format_string(string format)
More or less like sprintf.
%[field width][character]
0<=width>=2
Supported characters:
%: Insert a %
p or P: The percentage completed, with 'digits' number of decimals
v or V: The actual value, with digits decimals.
l or L: The lower value (from the adjustment)
u or U: The higer value (from the adjustment)
%: Insert a %
The default format is '%P%%'
GTK.Progress set_percentage(float pct)
Sets the value (between 0.0 and 1.0). Uses the min and max values.
GTK.Progress set_show_text(int textp)
If true, write a text in the progress bar.
GTK.Progress set_text_alignment(float xalign, float yalign)
The location for the text in the progress bar. xalign is between 0.0 (leftmost) and 1.0 (rightmost) yalign is between 0.0 (topmost) and 1.0 (bottommost)
Default is xalign == yalign == 0.5
GTK.Progress set_value(float value)
Set the value.
| CLASS GTK.Widget |
The basic widget, inherited (directly or indirectly) by all widgets. Thus, all functions and signals defined in this widget works on all widgets.
One of the most importat functions in this class is 'show', it lets GTK know that we are done setting the attributes of the widget, and it is ready to be displayed. You may also use hide to make it disappear again. The order in which you show the widgets is not important, but I suggest showing the toplevel window last so the whole window pops up at once rather than seeing the individual widgets come up on the screen as they're formed. The children of a widget (a window is a widget too) will not be displayed until the window itself is shown using the show() function.
Signals: add_accelerator Called when an accelarator (keyboard shortcut) is added to the widget
button_press_event Called when a mouse button is pressed
button_release_event Called when a mouse button is released
client_event An event sent by another client application
configure_event The size, position or stacking order of the widget has changed
debug_msg
delete_event Called when the user has requested that the widget should be closed
destroy_event Called when the widget is destroyed
drag_begin Called when the drag is initiated, on the sending side
drag_data_delete Called when the data can be safely deleted (there is no need to use this function in pigtk, it's all handled automatically)
drag_data_get Called on the sending side when the drop is initiated
drag_data_received Called on the receiving side when the drop is finished.
drag_drop Called on the receiving side when the drop is initiated
drag_end Called when the drag is finished, on the sending side
drag_leave Called when the mouse leaves the widget while the user is dragging something
drag_motion Called on the receiving side when the cursor is moved over the widget while dragging something
draw Called when the widget should draw itself.
draw_default Called when the widget should draw itself, and indicate that it's the default widget
draw_focus Called when the widget should draw itself, and a focus indicator around itself (or otherwise indicate that is has the keyboard focus)
enter_notify_event Called when the mouse enters the widget
event Called for all events
expose_event Called when the widget, or a part of the widget gets and expose event
focus_in_event The keyboard focus has entered the widget
focus_out_event The keyboard focus has left the widget
hide Called when the widget is hidden
key_press_event Called when a keyboard key is pressed
key_release_event Called when a keyboard key is released
leave_notify_event Called when the mouse leaves the widget
map Called when the window associated with the widget is mapped
map_event Called just before the 'map' signal
motion_notify_event Called when the mouse is moved inside the widget
no_expose_event
other_event
parent_set Called when the parent widget is changed
property_notify_event Called when a property of the GDK window associated with the widget is changed
proximity_in_event
proximity_out_event
realize Called when the widget is realized. Some methods cannot be used until the widget has been realized, if you get assertion errors related to 'w->window' or similar, this is probably the cause.
remove_accelerator Called when an accelerator (keyboard shortcut) is removed from the widget
selection_clear_event NYI
selection_notify_event NYI
selection_received NYI
selection_request_event NYI
show Called when the widget is shown
size_allocate Called when the widget gets the size it should be
size_request Called when the widget should calculate how big it wants to be
state_changed
style_set Called when the style is changed
unmap Called when the window associated with the widget is unmapped
unmap_event Called just before the 'unmap' signal
unrealize Called when the widget is unrealized.
visibility_notify_event The widget has been mapped, unmapped, hidden, or otherwise had its visibility modified
inherit GTK.Object : Object
GTK.Widget activate()
Activate the widget. This either activates the widget, if possible (as an example, buttons can be activated), or activates the default widget of its parent (or its parent, or its parents parent etc.)
GTK.Widget add_accelerator(string signal, GTK.AccelGroup group, int key, int modifiers, int flags)
Add an accelerator (keyboard shortcut).
Flag is one of ACCEL_LOCKED , ACCEL_SIGNAL_VISIBLE and ACCEL_VISIBLE
The signal is the signal to invoke when the accelerator key is pressed.
The modifiers is a bitwise or of one or more of GDK.ShiftMask, GDK.LockMask, GDK.ControlMask, GDK_MOD1_MASK , GDK_MOD2_MASK , GDK_MOD3_MASK , GDK_MOD4_MASK and GDK_MOD5_MASK .
The group is the accelerator group in which the accelerator should be added.
The key is the unicode code for the key to bind.
GTK.Widget add_events(int events)
Events is one or more of: GDK.ExposureMask, GDK.PointerMotionMask, GDK.PointerMotion_HINTMask, GDK.ButtonMotionMask, GDK.Button1MotionMask, GDK.Button2MotionMask, GDK.Button3MotionMask, GDK.ButtonPressMask, GDK.ButtonReleaseMask, GDK.KeyPressMask, GDK.KeyReleaseMask, GDK.EnterNotifyMask, GDK.LeaveNotifyMask, GDK.FocusChangeMask, GDK.StructureMask, GDK.PropertyChangeMask, GDK.VisibilityNotifyMask, GDK.ProximityInMask, GDK.ProximityOutMask and GDK.AllEventsMask
mapping allocation()
Returns ([ "x":xoffset, "y":yoffset, "width":xsize, "height":ysize ])
string class_path()
Returns the class 'pathname' of this widget. Useful for rc-files and such.
GTK.Widget copy_area(GDK.GC gc, int xdest, int ydest, GTK.Widget source, int xsource, int ysource, int width, int height)
Copies the rectangle defined by xsource,ysource and width,height from the source widget, and places the results at xdest,ydest in the widget in which this function is called. NOTE: The widget must be realized before this function can be used
GTK.Widget drag_dest_set(int flags, array targets, int actions)
Register a drop site, and possibly add default behaviors. arguments: flags: Which types of default drag behavior to use (one of DEST_DEFAULT_ALL , DEST_DEFAULT_DROP , DEST_DEFAULT_HIGHLIGHT and DEST_DEFAULT_MOTION ) targets: Table of targets that can be accepted ({ ({ content_type(string), flags(int(try 0)), id(int) }), ...}) The id will be received in the signal handlers. actions: one of GDK_ACTION_ASK , GDK_ACTION_COPY , GDK_ACTION_DEFAULT , GDK_ACTION_LINK , GDK_ACTION_MOVE and GDK_ACTION_PRIVATE results:
GTK.Widget drag_dest_unset()
Removes the drop support from this widget (see drag_dest_set)
GTK.Widget drag_get_data(GDK.DragContext ctx, int time)
Get the data from a context and an integer timestamp (from an event), requesting it from the dropping client. This function should probably never be used directly.
Use the selection argument passed to the drag_data_received signal instead.
GTK.Widget drag_highlight()
Highlight the widget. Not normaly used directly.
GTK.Widget drag_source_set(int flags, array targets, int actions)
Register a drop site, and possibly add default behaviors. arguments: buttons: Which mouse buttons can be used to start the drag targets: Table of targets that can be accepted ({ ({ content_type(string), flags(int(try 0)), id(int) }), ...}) The id will be received in the signal handlers. actions: one of GDK_ACTION_ASK , GDK_ACTION_COPY , GDK_ACTION_DEFAULT , GDK_ACTION_LINK , GDK_ACTION_MOVE and GDK_ACTION_PRIVATE results:
GTK.Widget drag_source_set_icon(GDK.Pixmap pm, GDK.Bitmap mask)
Set the icon that will be used (by default) for drags from this widget.
GTK.Widget drag_source_unset()
Remove the drag support from this widget. See drag_source_set.
GTK.Widget drag_unhighlight()
Unhighlight the widget. Not normaly used directly.
GTK.Widget ensure_style()
Ensure that the widget has a style associated with it.
string get_composite_name()
Like set name, but it is inherited by the children of this widget.
int get_events()
Return the current event mask (see set_events and add_events)
int get_extension_events()
Returns one of GDK_EXTENSION_EVENTS_ALL , GDK_EXTENSION_EVENTS_CURSOR and GDK_EXTENSION_EVENTS_NONE
GDK.Window get_gdkwindow()
Return the GDK.Window associated with this widget, if any.
string get_name()
Returns the name set by set_name or the class name
GTK.Widget get_parent()
Returns the parent of this widget, if any, if there is no parent 0 is returned.
GTK.Style get_style()
Return the style associated with this widget
GTK.Widget get_toplevel()
return the toplevel widget this widget is inside (or this widget if it is the toplevel widget)
GTK.Widget grab_default()
Make this widget the default action for the parent widget
GTK.Widget grab_focus()
Grab the focus.
int has_set_flags(int mask)
All possible flags are: GTK.AppPaintable, GTK.CanDefault, GTK.CanFocus, GTK.CompositeChild, GTK.HasDefault, GTK.HasFocus, GTK.HasGrab, GTK.Mapped, GTK.NoReparent, GTK.NoWindow, GTK.ParentSensitive, GTK.RcStyle, GTK.Realized, GTK.ReceivesDefault GTK.Sensitive, GTK.Toplevel and GTK.Visible.
GTK.Widget hide()
Hide this widget
GTK.Widget hide_all()
Hide this widget and all its children
int intersect(GDK.Rectangle area, GDK.Rectangle intersection)
Do an intersection with the area and place the result in 'intersection'.
int is_ancestor(GTK.Widget of)
Returns true if the specified widget is an ancestor of this widget.
GTK.Widget lock_accelerators()
Make it impossible to add new accelerators, or remove old ones
GTK.Widget map()
Map the widget. Should normally not be called directly.
string path()
Returns the 'pathname' of this widget. Useful for rc-files and such.
GTK.Widget popup(int xpos, int ypos)
Map the widget at the specified coordinates.
GTK.Widget queue_clear()
Force a clear (and subsequent redraw) of the widget
GTK.Widget queue_clear_area(int x, int y, int width, int height)
Force a clear (and subsequent redraw) of part of the widget
GTK.Widget queue_draw()
Force a redraw of the widget
GTK.Widget queue_draw_area(int x, int y, int width, int height)
Force a redraw of part of the widget
GTK.Widget queue_resize()
Force a allocation recalculation, followed by a redraw
GTK.Widget realize()
Realize this widget, and its children, if nessesary
GTK.Widget remove_accelerator(GTK.AccelGroup group, int key, int modifiers)
Remove an accelerator (keyboard shortcut).
The modifiers is a bitwise or of one or more of GDK.ShiftMask, GDK.LockMask, GDK.ControlMask, GDK_MOD1_MASK , GDK_MOD2_MASK , GDK_MOD3_MASK , GDK_MOD4_MASK and GDK_MOD5_MASK .
The group is the accelerator group in which the accelerator should be added.
The key is the unicode code for the key to bind.
GTK.Widget reparent(GTK.Widget to)
Change the parent of the widget.
GTK.Widget reset_rc_styles()
Reset all styles to their default value, recursively
GTK.Widget restore_default_style()
Reset all styles to their default value
GTK.Widget selection_add_target(GDK.Atom|void selection, GDK.Atom|void target, int|void info)
Supplying the selection is a bit more complicated than requesting it. You must register handlers that will be called when your selection is requested. For each selection/target pair you will handle, you make a call to this function.
selection, and target identify the requests this handler will manage. When a request for a selection is received, the "selection_get" signal will be called. info can be used as an enumerator to identify the specific target within the callback function.
Selection defaults to PRIMARY, and target defaults to STRING.
GTK.Widget selection_owner_set(GDK.Atom|void selection, int|void time)
When prompted by the user, you claim ownership of the selection by calling this function.
If another application claims ownership of the selection, you will receive a "selection_clear_event".
The selection defaults to the PRIMARY selection, and the time to GDK.CurrentTime.
int selecton_convert(GDK.Atom|void selection, GDK.Atom|void target, int|void time)
Retrieving the selection is an asynchronous process. To start the process, you call this function.
This converts the selection into the form specified by target. If at all possible, the time field should be the time from the event that triggered the selection. This helps make sure that events occur in the order that the user requested them. However, if it is not available (for instance, if the conversion was triggered by a "clicked" signal), then you can omit it altogether. This will cause it to be set to GDK.CurrentTime.
When the selection owner responds to the request, a "selection_received" signal is sent to your application. The handler for this signal receives a pointer to a GTK.SelectionData object.
The special target TARGETS generates a list of all valid targets.
Selection defaults to PRIMARY, and target defaults to STRING.
GTK.Widget set_app_paintable(int paintablep)
Make it possible to draw directly in the widget using the low-level drawing functions.
GTK.Widget set_background(GDK.Color background)
Set the background color or image. The argument is either a GDK.Pixmap or a GDK.Color object. NOTE: The widget must be realized before this function can be used
GTK.Widget set_bitmap_cursor(GDK.Bitmap source, GDK.Bitmap mask, GDK.Color fg, GDK.Color bg, int xhot, int yhot)
xhot and yhot are the locations of the x and y hotspot relative to the upper left corner of the cursor image. Both the bitmaps and the colors must be specified.
GTK.Widget set_composite_name(string name)
Like set name, but it is inherited by the children of this widget.
GTK.Widget set_cursor(int|void cursor_type, GDK.Color fg, GDK.Color bg)
Change the widget cursor. If no arguments are passed, restore the default cursor. Both fg and bg must be specified if either one is. <table border="0" cellpadding="3" cellspacing="0"> CURS(GDK.Arrow) CURS(GDK.BasedArrowDown) CURS(GDK.BasedArrowUp) CURS(GDK.Boat) CURS(GDK.Bogosity) CURS(GDK.BottomLeftCorner) CURS(GDK.BottomRightCorner) CURS(GDK.BottomSide) CURS(GDK.BottomTee) CURS(GDK.BoxSpiral) CURS(GDK.CenterPtr) CURS(GDK.Circle) CURS(GDK.Clock) CURS(GDK.CoffeeMug) CURS(GDK.Cross) CURS(GDK.CrossReverse) CURS(GDK.Crosshair) CURS(GDK.DiamondCross) CURS(GDK.Dot) CURS(GDK.Dotbox) CURS(GDK.DoubleArrow) CURS(GDK.DraftLarge) CURS(GDK.DraftSmall) CURS(GDK.DrapedBox) CURS(GDK.Exchange) CURS(GDK.Fleur) CURS(GDK.Gobbler) CURS(GDK.Gumby) CURS(GDK.Hand1) CURS(GDK.Hand2) CURS(GDK.Heart) CURS(GDK.Icon) CURS(GDK.IronCross) CURS(GDK.LeftPtr) CURS(GDK.LeftSide) CURS(GDK.LeftTee) CURS(GDK.Leftbutton) CURS(GDK.LlAngle) CURS(GDK.LrAngle) CURS(GDK.Man) CURS(GDK.Middlebutton) CURS(GDK.Mouse) CURS(GDK.Pencil) CURS(GDK.Pirate) CURS(GDK.Plus) CURS(GDK.QuestionArrow) CURS(GDK.RightPtr) CURS(GDK.RightSide) CURS(GDK.RightTee) CURS(GDK.Rightbutton) CURS(GDK.RtlLogo) CURS(GDK.Sailboat) CURS(GDK.SbDownArrow) CURS(GDK.SbHDoubleArrow) CURS(GDK.SbLeftArrow) CURS(GDK.SbRightArrow) CURS(GDK.SbUpArrow) CURS(GDK.SbVDoubleArrow) CURS(GDK.Shuttle) CURS(GDK.Sizing) CURS(GDK.Spider) CURS(GDK.Spraycan) CURS(GDK.Star) CURS(GDK.Target) CURS(GDK.Tcross) CURS(GDK.TopLeftArrow) CURS(GDK.TopLeftCorner) CURS(GDK.TopRightCorner) CURS(GDK.TopSide) CURS(GDK.TopTee) CURS(GDK.Trek) CURS(GDK.UlAngle) CURS(GDK.Umbrella) CURS(GDK.UrAngle) CURS(GDK.Watch) CURS(GDK.Xterm) </table>
GTK.Widget set_events(int events)
Events is one or more of: GDK.ExposureMask, GDK.PointerMotionMask, GDK.PointerMotion_HINTMask, GDK.ButtonMotionMask, GDK.Button1MotionMask, GDK.Button2MotionMask, GDK.Button3MotionMask, GDK.ButtonPressMask, GDK.ButtonReleaseMask, GDK.KeyPressMask, GDK.KeyReleaseMask, GDK.EnterNotifyMask, GDK.LeaveNotifyMask, GDK.FocusChangeMask, GDK.StructureMask, GDK.PropertyChangeMask, GDK.VisibilityNotifyMask, GDK.ProximityInMask, GDK.ProximityOutMask and GDK.AllEventsMask
GTK.Widget set_extension_events(int events)
Events is one of GDK_EXTENSION_EVENTS_ALL , GDK_EXTENSION_EVENTS_CURSOR and GDK_EXTENSION_EVENTS_NONE
GTK.Widget set_flags(int flags)
The flags that it makes sense to set are: GTK.CanFocus and GTK.CanDefault
GTK.Widget set_name(string name)
Set the name of the widget. The name is used when the rc-file is parsed, you can also parse your own resources by calling GTK.parse_rc() with a resource string. Example: TODO
GTK.Widget set_rc_style()
Set the style from the .rc files
int set_scroll_adjustments(GTK.Adjustment hadjustment, GTK.Adjustment vadjustment)
Set the scrolling (panning) adjustment objects for this widget. Returns 1 if it is possible to do so, and 0 otherwise.
GTK.Widget set_sensitive(int sensitivep)
True (1) or false (0). If true, the widget can receive events, otherwise the user cannot interact with the widget. Most widgets are drawn 'greyed' or more dim when they are unsensitive.
GTK.Widget set_state(int state)
One of STATE_ACTIVE , STATE_INSENSITIVE , STATE_NORMAL , STATE_PRELIGHT and STATE_SELECTED . This function should normaly not be used directly.
GTK.Widget set_style(GTK.Style cf)
Set the style to be associated with this widget
GTK.Widget set_uposition(int xpos, int ypos)
Set the absolute coordinates of the widget relative to its parent.
GTK.Widget set_usize(int xsize, int ysize)
Set the absolute size of the widget. It might resize itself anyway, but this size is used as is in most widgets. Beware of this function, it might produce unexpected results. 0 for any size means 'keep old size'. When setting sizes of wtoplevel windows, it is preferable to use set_default_size
GTK.Widget shape_combine_mask(GDK.Bitmap shape, int xoffset, int yoffset)
Set the shape of the widget, or, rather, its window, to that of
the supplied bitmap. Notice how the window behind the example
window can be seen because of the rather odd shape the example window has.
GTK.Window( GTK.WINDOW_TOPLEVEL )->add(GTK.Label("A rather Oddly shaped\n" "Window\n" "Indeed\n" "Or what do you\nthink?\n" "This text\n" "should\n" "be long enough"))->shape_combine_mask( GDK.Bitmap(Image.Image(100,100,255,255,255)->rotate(10,0,0,0) ), 20,20)

NOTE: The widget must be realized before this function can be used
GTK.Widget show()
Show the widget. Most (almost all) widgets must be shown to be visible on the screen.
GTK.Widget show_all()
Show this widget and all its children
GTK.Widget show_now()
Show this widget and do not return until it is visible.
int text_width(string text)
Returns the width, in pixels, the string would have if it was written with the default font in the style object assosiated with the widget.
GTK.Widget unlock_accelerators()
Make it possible to add new accelerators, and remove old ones, again. Use this after lock_accelerators()
GTK.Widget unmap()
Unmap the widget. Should normally not be called directly.
GTK.Widget unparent()
Remove this widget from its parent
GTK.Widget unrealize()
Unrealize this widget, and its children, if nessesary
GTK.Widget unset_flags(int flags)
The flags that it makes sense to unset are: GTK.CanFocus and GTK.CanDefault
int xoffset()
Returns the x position of the upper left corner relative to the widgets window in pixels. For widgets that have their own window this will most likely be 0.
int xsize()
Returns the width of the widget in pixels.
int yoffset()
Returns the y position of the upper left corner relative to the widgets window in pixels. For widgets that have their own window this will most likely be 0.
int ysize()
Returns the height of the widget in pixels.
| CLASS GTK.HbuttonBox |
A HbuttonBox is very similar to a Hbox. The major diffference is that the button box is made to pack buttons in, and has a few convenience function for normal button layouts.
GTK.HbuttonBox()->add(GTK.Button("Hello"))->add(GTK.Button("World"))->set_usize(400,30)
![]()
GTK.HbuttonBox()->add(GTK.Button("Hello"))->add(GTK.Button("World"))->set_layout(GTK.BUTTONBOX_SPREAD)->set_usize(400,30)
![]()
GTK.HbuttonBox()->add(GTK.Button("Hello"))->add(GTK.Button("World"))->set_layout(GTK.BUTTONBOX_EDGE)->set_usize(400,30)
![]()
GTK.HbuttonBox()->add(GTK.Button("Hello"))->add(GTK.Button("World"))->set_layout(GTK.BUTTONBOX_START)->set_usize(400,30)
![]()
GTK.HbuttonBox()->add(GTK.Button("Hello"))->add(GTK.Button("World"))->set_layout(GTK.BUTTONBOX_END)->set_usize(400,30)
![]()
inherit GTK.ButtonBox : ButtonBox
GTK.HbuttonBox GTK.HbuttonBox()
Create a new horizontal button box
| CLASS GTK.Misc |
The GTK.Misc widget is an abstract widget which is not useful itself, but is used to derive subclasses which have alignment and padding attributes.
The horizontal and vertical padding attributes allows extra space to be added around the widget.
The horizontal and vertical alignment attributes enable the widget to be positioned within its allocated area. Note that if the widget is added to a container in such a way that it expands automatically to fill its allocated area, the alignment settings will not alter the widgets position.
GTK.Vbox(0,0)->add(GTK.Label("Label"))->set_usize(100,20)
![]()
GTK.Vbox(0,0)->add(GTK.Label("Label")->set_alignment(1.0,0.0))->set_usize(100,20)
![]()
GTK.Vbox(0,0)->add(GTK.Label("Label")->set_alignment(0.0,0.0))->set_usize(100,20)
![]()
inherit GTK.Widget : Widget
float get_xalign()
The horizontal alignment, from 0 (left) to 1 (right).
int get_xpad()
The amount of space to add on the left and right of the widget, in pixels.
float get_yalign()
The vertical alignment, from 0 (top) to 1 (botton).
int get_ypad()
The amount of space to add on the top and bottom of the widget, in pixels.
GTK.Misc set_alignment(float xalign, float yalign)
Sets the alignment of the widget. 0.0 is left or topmost, 1.0 is right or bottommost.
GTK.Misc set_padding(int xpad, int ypad)
Sets the amount of space to add around the widget. xpand and ypad are specified in pixels.
| CLASS GTK.Databox |
GtkDatabox is designed to display large amounts of numerical data fast and easy. Thousands of data points (X and Y coordinate) may be displayed without any problems, zooming and scrolling as well as optional rulers are already included.
The widget may be used as display for oscilloscopes or other applications that need to display fast changes in their data.
GTK.Databox x=GTK.Databox(); x->data_add_x_y(3, ({ 1.0, 0.5, 0.0 }), ({1.0, -1.0, 0.0}),GDK.Color(Image.Color.red), GTK.DataboxLines,2); x->rescale(); x->set_usize(300,300); return x;
![]()
Signals: marked
selection_canceled
selection_changed
selection_started
selection_stopped
zoomed
inherit GTK.Vbox : Vbox
GTK.Databox GTK.Databox()
Create a new databox widget
int data_add_x(int nelems, array x, int shared_Y_index, GDK.Color color, int type, int dot_size)
Type is one of DATABOX_BARS , DATABOX_LINES , DATABOX_NOT_DISPLAYED and DATABOX_POINTS
int data_add_x_y(int nelems, array x, array y, GDK.Color color, int type, int dot_size)
Type is one of DATABOX_BARS , DATABOX_LINES , DATABOX_NOT_DISPLAYED and DATABOX_POINTS
int data_add_y(int nelems, array y, int shared_X_index, GDK.Color color, int type, int dot_size)
Type is one of DATABOX_BARS , DATABOX_LINES , DATABOX_NOT_DISPLAYED and DATABOX_POINTS
int data_destroy(int index)
int data_destroy_all()
array data_get_extrema()
mapping data_get_value(int x, int y)
array data_get_visible_extrema()
GTK.Databox disable_zoom()
GTK.Databox enable_zoom()
GTK.Databox hide_cross()
GTK.Databox hide_rulers()
GTK.Databox hide_scrollbars()
GTK.Databox rescale()
GTK.Databox rescale_with_values(float minx, float miny, float maxx, float maxy)
int set_color(int index, GDK.Color color)
int set_data_type(int index, int type, int dot_size)
Type is one of DATABOX_BARS , DATABOX_LINES , DATABOX_NOT_DISPLAYED and DATABOX_POINTS
GTK.Databox show_cross()
GTK.Databox show_rulers()
GTK.Databox show_scrollbars()
| CLASS GTK.Plug |
Together with W(Socket), GTK.Plug provides the ability to embed widgets from one process into another process in a fashion that is transparent to the user. One process creates a W(Socket) widget and, passes the XID of that widgets window to the other process, which then creates a GTK.Plug window with that XID. Any widgets contained in the GTK.Plug then will appear inside the first applications window.
inherit GTK.Window : Window
GTK.Plug GTK.Plug(int socket_id)
Create a new plug, the socket_id is the window into which this plug will be plugged.
int get_same_app()
returns 1 if the socket the plug is connected to is in this application.
| CLASS GTK.ColorSelectionDialog |
The color selection dialog widget is, not surprisingly, a color selection widget in a dialog window. Use the subwidget functions below to access the different subwidgets directly.
GTK.ColorSelectionDialog("Select color")

Signals: color_changed Called when the color is changed
inherit GTK.Window : Window
GTK.ColorSelectionDialog GTK.ColorSelectionDialog(string title)
Create a new color selection dialog with the specified title.
GTK.Button get_cancel_button()
Return the cancel button widget.
GTK.ColorSelection get_colorsel()
Return the color selection widget
GTK.Button get_help_button()
Return the help button
GTK.Button get_ok_button()
Return the ok button
| CLASS GTK.FileSelection |
GtkFileSelection should be used to retrieve file or directory names from the user. It will create a new dialog window containing a directory list, and a file list corresponding to the current working directory. The filesystem can be navigated using the directory list, the drop-down history menu, or the TAB key can be used to navigate using filename completion common in text based editors such as emacs and jed.
The default filename can be set using set_filename() and the selected filename retrieved using get_filename().
Use complete() to display files that match a given pattern. This can be used for example, to show only *.txt files, or only files beginning with gtk*.
Simple file operations; create directory, delete file, and rename file, are available from buttons at the top of the dialog. These can be hidden using hide_fileop_buttons() and shown again using show_fileop_buttons().
GTK.FileSelection("File selector")

inherit GTK.Window : Window
GTK.FileSelection complete(string pattern)
Will attempt to match pattern to a valid filename in the current directory. If a match can be made, the matched filename will appear in the text entry field of the file selection dialog. If a partial match can be made, the "Files" list will contain those file names which have been partially matched.
GTK.FileSelection GTK.FileSelection(string window_title)
Creates a new file selection dialog box. By default it will list the files in the current working directory. Operation buttons allowing the user to create a directory, delete files, and rename files will also be present by default.
GTK.Button get_cancel_button()
The cancel button
GTK.Clist get_dir_list()
The list of directories
GTK.Clist get_file_list()
The list of files
string get_filename()
Returns the currently entered filename as a string
GTK.Button get_fileop_c_dir()
The create directory button in the file operation button group
GTK.Button get_fileop_del_file()
The delete file button in the file operation button group
GTK.Button get_fileop_ren_file()
The rename file button in the file operation button group
GTK.Button get_help_button()
The help button
GTK.OptionMenu get_history_pulldown()
Used to create the drop-down directory histor
GTK.Button get_ok_button()
The ok button
GTK.FileSelection hide_fileop_buttons()
Hides the file operation buttons that normally appear at the top of the dialog. Useful if you wish to create a custom file selector, based on GTK.FileSelection.
GTK.FileSelection set_filename(string fname)
Sets a default path for the file requestor. If filename includes a directory path, then the requestor will open with that path as its current working directory.
GTK.FileSelection show_fileop_buttons()
Shows the file operation buttons, if they have previously been hidden. The rest of the widgets in the dialog will be resized accordingly.
| CLASS GTK.Clist |
The GtkCList widget is a multi-column list widget that is capable
of handling literally thousands of rows of information. Each column
can optionally have a title, which itself is optionally active,
allowing us to bind a function to it's selection.
GTK.Clist(2)->set_column_title(0,"Col 1")->set_column_title(1,"Col 2")->column_titles_show()->set_column_width(0,50)->set_usize(150,70)

Signals: abort_column_resize
click_column Called when a column is clicked
end_selection
extend_selection
resize_column Called when a column is resized
scroll_horizontal
scroll_vertical
select_all
select_row Called when a row is selected
start_selection
toggle_add_mode
toggle_focus_row
undo_selection
unselect_all
unselect_row Called when a row is deselected
inherit GTK.Container : Container
int append(array columns)
The return value of indicates the index of the row that was just added.
'columns' are the texts we want to put in the columns. The size of the array should equal the number of columns in the list.
GTK.Clist clear()
remove all rows
GTK.Clist column_title_active(int column)
Make a specific column title active
GTK.Clist column_title_passive(int column)
Make a specific column title passive
GTK.Clist column_titles_active()
The column titles can be pressed
GTK.Clist column_titles_hide()
Hide the column titles
GTK.Clist column_titles_passive()
The column titles can't be pressed
GTK.Clist column_titles_show()
Show the column titles.
int columns_autosize()
Resize all columns according to their contents
GTK.Clist GTK.Clist(int columns)
Create a new empty clist, columns columns wide.
Not all columns have to be visible, some can be used to store data that is related to a certain cell in the list.
int find_row_from_data(object data)
Find a row in the list that has the given user data. If no node is found, -1 is returned.
GTK.Clist freeze()
freeze all visual updates of the list, and then thaw the list after you have made a number of changes and the updates wil occure in a more efficent mannor than if you made them on a unfrozen list
GDK.Color get_background(int row)
Return the background color of a specified row
GTK.Style get_cell_style(int row, int col)
return the W(Style) associated with a specific cell
int get_cell_type(int row, int column)
Return value is one of CELL_EMPTY , CELL_PIXMAP , CELL_PIXTEXT , CELL_TEXT and CELL_WIDGET
string get_column_title(int column)
Returns the title of a specified column.
GTK.Widget get_column_widget(int column)
Return the widget for the specified column title
int get_columns()
Return the number of columns in this clist
int get_drag_button()
Return the button used to drag items (by default 1)
int get_flags()
Return the flags. A bitwise or of CLIST_ADD_MODE , CLIST_AUTO_RESIZE_BLOCKED , CLIST_AUTO_SORT , CLIST_DRAW_DRAG_LINE , CLIST_DRAW_DRAG_RECT , CLIST_IN_DRAG , CLIST_REORDERABLE , CLIST_ROW_HEIGHT_SET , CLIST_SHOW_TITLES and CLIST_USE_DRAG_ICONS
int get_focus_row()
The currently focused row
GDK.Color get_foreground(int row)
Return the foregroun color for the specified row
GTK.Adjustment get_hadjustment()
Return the W(Adjustment) object used for horizontal scrolling
GTK.Clist get_pixmap(int row, int column)
Return the pixmap for the specified cell
mapping get_pixtext(int row, int col)
Return the pixmap and text for the specified cell as a mapping: ([ "spacing":spacing, "text":text, "pixmap":pixmap ])
object get_row_data(int row)
Return the data associated with a row, or 0.
int get_row_height()
Return the height of the row
GTK.Style get_row_style(int row)
Return the W(style) object associated with the specified row
int get_rows()
Return the number of rows
int get_selectable(int row)
Return 1 if the specified row can be selected by the user.
array get_selection()
Return an array with all selected rows.
mapping get_selection_info(int x, int y)
Return the row column corresponding to the x and y coordinates, the returned values are only valid if the x and y coordinates are relative to the clist window coordinates
int get_selection_mode()
Return the selection mode. One of SELECTION_BROWSE , SELECTION_EXTENDED , SELECTION_MULTIPLE and SELECTION_SINGLE
int get_shadow_type()
Return the curreent shadow type. One of SHADOW_ETCHED_IN , SHADOW_ETCHED_OUT , SHADOW_IN , SHADOW_NONE and SHADOW_OUT
int get_sort_column()
The column that will be used to sort the rows
int get_sort_type()
The sort method, one of SORT_ASCENDING and SORT_DESCENDING
GTK.Clist get_text(int row, int col)
Return the text associated with a specific cell.
GTK.Adjustment get_vadjustment()
Return the W(Adjustment) object used for vertical scrolling
int insert(int row, array columns)
Insert a row after a specified row. The return value of indicates the index of the row that was just added, please note that this is not nessasarily the same row as the specified one, if autosort is activated, the row will be inserted so that the list is sill sorted.
'columns' are the texts we want to put in the columns. The size of the array should equal the number of columns in the list.
GTK.Clist moveto(int row, int column, float xpos, float ypos)
Make the specified row and column visible, and place it relative to xpos and ypos in the area the Clist occupies. xpos and ypos are relative, 0.0 == top, 1.0 == bottom
int optimal_column_width(int column)
Return the optimal width of the specified column
int prepend(array columns)
The return value of indicates the index of the row that was just added.
'columns' are the texts we want to put in the columns. The size of the array should equal the number of columns in the list.
GTK.Clist remove(int row)
Delete a specified row. If you want to remove all rows in a Clist, use 'clear()' instead of calling remove multiple times.
GTK.Clist row_move(int from_row, int to_row)
Move the specified row to just before the specified destination row.
GTK.Clist select_all()
Select all rows
GTK.Clist select_row(int row, int column)
Select the given row. The column is sent to the signal handler, but ignored for all other purposes.
GTK.Clist set_auto_sort(int sortp)
If true, the clist will automatically be re-sorted when new rows are inserted. Please note that it will not be resorted if the text in cells are changed, use 'sort()' to force a reorder. The sort function is stable.
GTK.Clist set_background(int row, GDK.Color color)
Set the background color of the specified row the the specified color
GTK.Clist set_button_actions(int button, int action)
Action is a bitwise or of BUTTONBOX_DEFAULT_STYLE , BUTTONBOX_EDGE , BUTTONBOX_END , BUTTONBOX_SPREAD , BUTTONBOX_START , BUTTON_DRAGS , BUTTON_EXPANDS , BUTTON_IGNORED and BUTTON_SELECTS Button is the mouse button (normally 1-3, 4 and 5 sometimes beeing scroll wheel up and scroll wheel down)
GTK.Clist set_cell_style(int row, int column, GTK.Style style)
Set a W(Style) for a specific cell
GTK.Clist set_column_auto_resize(int column, int autoresizep)
Automatically resize a column to the width of it's widest contents.
GTK.Clist set_column_justification(int column, int justification)
justification is one of JUSTIFY_CENTER , JUSTIFY_FILL , JUSTIFY_LEFT and JUSTIFY_RIGHT
GTK.Clist set_column_max_width(int column, int width)
if width 6lt; 0 , there is no restriction
GTK.Clist set_column_min_width(int column, int width)
Width in pixels
GTK.Clist set_column_resizeable(int column, int resizeablep)
Make a column resizable, or remove it's the resizability.
GTK.Clist set_column_title(int column, string title)
Set the column title of a specified column. It is a good idea to set the titles before the column title buttons are shown.
GTK.Clist set_column_visibility(int column, int visiblep)
Hide or show a column
GTK.Clist set_column_widget(int column, GTK.Widget widget)
Put a widget as a column title. The widget will be added to a W(Button).
GTK.Clist set_column_width(int column, int width)
Width in pixels
GTK.Clist set_compare_func(function cmpfun)
Set the compare function. The function will be called with a
mapping as it's only argument, like this:
([
"clist":the clist widget,
"sort_column":the column to sort on,
"row1_data":The user data pointer for the first row,
"row2_data":The user data pointer for the second row,
"row1_text":The text in the sort cell in the first row
"row2_text":The text in the sort cell in the second row
])
The return value is one of:
1: Row 1 is more than row 2
0: The rows are equal
-1: Row 1 is lesser than row 2
To remove the comparefunction, use 0 as the argument.
GTK.Clist set_foreground(int row, GDK.Color color)
Set the foreground color of the specified row to the specified color
GTK.Clist set_hadjustment(GTK.Adjustment adjustment)
Set the W(Adjustment) object used for horizontal scrolling
GTK.Clist set_pixmap(int row, int col, GDK.Pixmap image, GDK.Bitmap mask)
Set the pixmap of the specified cell. The mask is optional
GTK.Clist set_pixtext(int row, int column, string text, int spacing, GDK.Pixmap image, GDK.Bitmap mask)
Set the pixmap and text of the specified cell. The mask is optional The spacing is the number of pixels between the pixmap and the text.
GTK.Clist set_reorderable(int reorderablep)
If true, the user can drag around the rows in the list.
GTK.Clist set_row_data(int row, object data)
Set the user data associated with the specified row. This data can be used to find rows, and when a row is selected it can be easily retrieved using node_get_row_data.
You can only use objects as row data right now
GTK.Clist set_row_height(int pixels)
in pixels
GTK.Clist set_row_style(int row, GTK.Style style)
GTK.Clist set_selectable(int row, int selectablep)
If true, the row can be selected by the user, otherwise it cannot be selected, only focused.
GTK.Clist set_selection_mode(int mode)
One of SELECTION_BROWSE , SELECTION_EXTENDED , SELECTION_MULTIPLE and SELECTION_SINGLE
GTK.Clist set_shadow_type(int shadowtype)
One of SHADOW_ETCHED_IN , SHADOW_ETCHED_OUT , SHADOW_IN , SHADOW_NONE and SHADOW_OUT
GTK.Clist set_shift(int row, int column, int yshift, int xshift)
The contents of the specified cell will be drawn shifted (indented) the specifid number of pixels.
This can be useful to generate a tree-like layout when you do not want to make a W(Ctree)
GTK.Clist set_sort_column(int column)
GTK.Clist set_sort_type(int direction)
Ascending or descending (One of SORT_ASCENDING and SORT_DESCENDING )
GTK.Clist set_text(int row, int column, string text)
Set the text for the specified cell. Please note that even if auto sorting is enabled, the row will not be resorted. Use the 'sort()' function.
GTK.Clist set_use_drag_icons(int dragiconsp)
If true, hard coded drag icons will be used.
GTK.Clist set_vadjustment(GTK.Adjustment adjustment)
Set the W(Adjustment) object used for vertical scrolling
GTK.Clist sort()
Set the column on which all sorting will be performed
GTK.Clist thaw()
freeze all visual updates of the list, and then thaw the list after you have made a number of changes and the updates wil occure in a more efficent mannor than if you made them on a unfrozen list
GTK.Clist undo_selection()
Undo the previous selection
GTK.Clist unselect_all()
Unselect all rows
GTK.Clist unselect_row(int row, int column)
Unselect the given row. The column is sent to the signal handler, but ignored for all other purposes.
| CLASS GTK.Socket |
Together with W(Plug), GTK.Socket provides the ability to embed widgets from one process into another process in a fashion that is transparent to the user. One process creates a GTK.Socket widget and, passes the XID of that widget's window to the other process, which then creates a W(Plug) window with that XID. Any widgets contained in the W(Plug) then will appear inside the first applications window.
Note that if you pass the XID of the socket to another process that will create a plug in the socket, you must make sure that the socket widget is not destroyed until that plug is created. Violating this rule will cause unpredictable consequences, the most likely consequence being that the plug will appear as a separate toplevel window.
A socket can also be used to swallow arbitrary pre-existing top-level windows using steal(), though the integration when this is done will not be as close as between a W(Plug) and a GTK.Socket.
inherit GTK.Container : Container
GTK.Socket GTK.Socket()
int get_same_app()
return 1 if the widow contained in this socket comes from this process.
int has_plug()
Returns true if this socket is occupied
int id()
Returns the window id, to be sent to the application providing the plug. You must realize this widget before calling this function.
GTK.Socket steal(int window_id)
Reparents a pre-existing toplevel window (not nessesarily a GTK window) into a socket.
| CLASS GTK.CheckButton |
Check buttons inherent many properties and functions from the the
toggle buttons, but look a little different. Rather than
being buttons with text inside them, they are small squares with
the text to the right of them. These are often used for toggling
options on and off in applications.
GTK.Check_button( "title" )
![]()
inherit GTK.ToggleButton : ToggleButton
GTK.CheckButton GTK.CheckButton(string|void label)
The argument, if specified, is the label of the item. If no label is specified, use object->add() to add some other widget (such as an pixmap or image widget)
| CLASS GTK.Adjustment |
The GTK.Adjustment object represents a value which has an associated lower and upper bound, together with step and page increments, and a page size. It is used within several GTK+ widgets, including GtkSpinButton, GtkViewport, and GtkRange (which is a base class for GtkHScrollbar, GtkVScrollbar, GtkHScale, and GtkVScale).
The GtkAdjustment object does not update the value itself. Instead it is left up to the owner of the GtkAdjustment to control the value.
The owner of the GtkAdjustment typically calls the value_changed() and changed() functions after changing the value or its bounds. This results in the emission of the "value_changed" or "changed" signal respectively.
Signals: changed The adjustment changed in some way
value_changed The value changed
inherit GTK.Data : Data
GTK.Adjustment changed()
Call this when you have modified anything except the value member of the adjustment.
GTK.Adjustment clamp_page(float lower, float upper)
Updates the GTK.Adjustment value to ensure that the range between lower and upper is in the current page (i.e. between value and value + page_size). If the range is larger than the page size, then only the start of it will be in the current page. A "value_changed" signal will be emitted if the value is changed.
GTK.Adjustment GTK.Adjustment(float|void value, float|void lower, float|void upper, float|void step_increment, float|void page_increment, float|void page_size)
The value argument is the initial value you want to give to the adjustment, usually corresponding to the topmost or leftmost position of an adjustable widget. The lower argument specifies the lowest value which the adjustment can hold. The step_increment argument specifies the "smaller" of the two increments by which the user can change the value, while the page_increment is the "larger" one. The page_size argument usually corresponds somehow to the visible area of a panning widget. The upper argument is used to represent the bottom most or right most coordinate in a panning widget's child. Therefore it is not always the largest number that value can take, since the page_size of such widgets is usually non-zero.
All values are optional, they default to 0.0. For most widgets the unit is pixels.
float get_lower()
Get the lower limit
float get_page_increment()
Get the page increment (page down or through click)
float get_page_size()
Get the page size (the actual size of a page)
float get_step_increment()
Get the step increment (arrow click)
float get_upper()
get the upper limit.
float get_value()
Get the value component.
float set_set_lower()
Set the lower limit.
float set_set_page_increment()
Set the page increment (page down or through click)
float set_set_page_size()
Set the page size (the actual size of a page)
float set_set_step_increment()
Set the step increment (arrow click)
float set_set_upper()
Set the upper limit.
GTK.Adjustment set_value(float to)
Set the value component.
| CLASS GTK.Ctree |
The GtkCTree widget is used for showing a hierarchical tree to the user, for example a directory tree.
The tree is internally represented as a set of GtkCTreeNode structures.
The interface has much in common with the GtkCList widget: rows (nodes) can be selected by the user etc.
Positions in the tree are often indicated by two arguments, a parent and a sibling, both GtkCTreeNode pointers. If the parent is NULL, the position is at the root of the tree and if the sibling is NULL, it will be the last child of parent, otherwise it will be inserted just before the sibling.
Signals: change_focus_row_expansion Changed when the focused row is either expanded or collapsed
tree_collapse Called when a node is collapsed
tree_expand Called when a node is expanded
tree_move Called when a node is moved (using DND, as an example)
tree_select_row Called when a node is selected.
tree_unselect_row Called when a node is unselected.
inherit GTK.Clist : Clist
GTK.Ctree collapse(GTK.CTreeNode node)
Collapse the node, hiding it's children. If no node is given, expand the toplevel of the tree
GTK.Ctree collapse_recursive(GTK.CTreeNode node)
Collapse the node, showing it's children, it's childrens children, etc. If no node is given, collapse the whole tree
GTK.Ctree collapse_to_depth(GTK.CTreeNode node, int depth)
Collapse depth levels of the tree, starting with the specified node. If no node is given, start with the toplevel node.
GTK.Ctree GTK.Ctree(int columns, int tree_column)
tree_column is the column that has the tree graphics (lines and expander buttons).
GTK.Ctree expand(GTK.CTreeNode node)
Expand the node, showing it's children. If no node is given, expand the toplevel of the tree
GTK.Ctree expand_recursive(GTK.CTreeNode node)
Expand the node, showing it's children, it's childrens children, etc. If no node is given, expand the whole tree
GTK.Ctree expand_to_depth(GTK.CTreeNode node, int depth)
Expand depth levels of the tree, starting with the specified node. If no node is given, start with the toplevel node.
int find(GTK.CTreeNode node, GTK.CTreeNode start)
Returns true if the node is a child of the start node.
If you omit the starting node, the tree will be searched from the root.
GTK.Ctree find_by_row_data(object data, CTreeNode|void root)
Find a node in the tree starting with root, that has the given user data. If no node is found, 0 is returned.
GTK.CTreeNode find_node_ptr(GTK.CTreeRow node)
Given a W(CTreeRow) (deprectated structure in PiGTK), return the W(CTreeNode) associated with the row.
int get_expander_style()
The style of the expander buttons, one of CTREE_EXPANDER_CIRCULAR , CTREE_EXPANDER_NONE , CTREE_EXPANDER_SQUARE and CTREE_EXPANDER_TRIANGLE
int get_line_style()
The style of the lines, one of CTREE_LINES_DOTTED , CTREE_LINES_NONE , CTREE_LINES_SOLID and CTREE_LINES_TABBED
int get_show_stub()
Will stubs be shows?
int get_tree_column()
The column that is the tree column (the one with the expand/collapse icons)
int get_tree_indent()
The number of pixels to indent the tree levels.
int get_tree_spacing()
The number of pixels between the tree and the columns
GTK.Ctree insert_node(GTK.CTreeNode parent, GTK.CTreeNode sibling, array text, int is_leaf, int expanded)
At least one of parent or sibling must be specified. If both are specified, sibling->parent() must be equal to parent.
If the parent and sibling is 0, the position is at the root of the tree, if the sibling is NULL, it will be the last child of parent, otherwise it will be inserted just before the sibling.
int is_ancestor(GTK.CTreeNode node, GTK.CTreeNode child)
Returns true if node is an ancestor of child
int is_hot_spot(int x, int y)
Returns true if the given coordinates lie on an expander button
int is_viewable(GTK.CTreeNode node)
Returns 1 if a certain node can be viewed (with or without scrolling of the tree). Returns 0 if the node is in a folded part of the tree.
GTK.CTreeNode last(GTK.CTreeNode node)
Returns the last child of the last child of the last child... of the given node.
GTK.Ctree move(GTK.CTreeNode node, GTK.CTreeNode new_parent, GTK.CTreeNode new_sibling)
Move a node. Coordinates work as for insert.
GTK.Style node_get_cell_style(GTK.CTreeNode node, int col)
Return the style of a cell
int node_get_cell_type(GTK.CTreeNode node, int column)
Return the celltype of this node.
mapping node_get_pixmap(CTreeNode node, int column)
Returns the pixmap and mask of this node in a mapping: ([ "pixmap":the_pixmap, "mask":the_bitmap ])
mapping node_get_pixtext(GTK.CTreeNode n, int columne)
Returns the pixmap, mask and text of this node in a mapping: ([ "pixmap":the_pixmap, "mask":the_bitmap, "text":the_text ])
object node_get_row_data(GTK.CTreeNode n)
Return the data associated with a node, or 0.
GTK.Style node_get_row_style(GTK.CTreeNode node)
Return the style of a row
int node_get_selectable(GTK.CTreeNode node)
Return whether or not this node can be selcted by the user
string node_get_text(GTK.CTreeNode node, int column)
Returns the text of the specified node
int node_is_visible(GTK.CTreeNode node)
Return 1 if the node is currently visible
GTK.Ctree node_moveto(GTK.CTreeNode row, int column, float row_align, float col_align)
Scroll the tree so a specified node (and column) is visible. If the node is folded, it's first visible parent will be shown.
GTK.CTreeNode node_nth(int row)
Return the node that is currently visible on the specified row.
GTK.Ctree node_set_background(GTK.CTreeNode node, GDK.Color color)
Set the background of a row
GTK.Ctree node_set_cell_style(GTK.CTreeNode node, int col, GTK.Style style)
Set the style of a cell
GTK.Ctree node_set_foreground(GTK.CTreeNode node, GDK.Color col)
Set the foreground of a row
GTK.Ctree node_set_pixmap(GTK.CTreeNode node, int column, GDK.Pixmap pixmap, GDK.Bitmap mask)
Set the pixmap in a cell
GTK.Ctree node_set_pixtext(GTK.CTreeNode node, int column, string text, int spacing, GDK.Pixmap pixmap, GDK.Bitmap mask)
Set the pixmap and text in a cell
GTK.Ctree node_set_row_data(GTK.CTreeNode node, object data)
Set the user data associated with the specified node. This data can be used to find nodes, and when a node is selected it can be easily retrieved using node_get_row_data.
You can only use objects as row data right now
GTK.Ctree node_set_row_style(GTK.CTreeNode node, GTK.Style style)
Set the style of a row
GTK.Ctree node_set_selectable(GTK.CTreeNode node, int selectablep)
Whether this node can be selected by the user.
GTK.Ctree node_set_shift(GTK.CTreeNode node, int column, int vertical, int horizontal)
Shift the given cell the given amounts in pixels.
GTK.Ctree node_set_text(GTK.CTreeNode node, int column, string text)
Set the text in a cell
GTK.Ctree remove_node(GTK.CTreeNode node)
Remove a node and it's subnodes from the tree. The nodes will be destroyed, so you cannot add them again.
GTK.Ctree select(GTK.CTreeNode node)
Select a node.
GTK.Ctree select_recursive(GTK.CTreeNode node)
Select a node and it's children.
GTK.Ctree set_expander_style(int style)
Set the expander style, one of CTREE_EXPANDER_CIRCULAR , CTREE_EXPANDER_NONE , CTREE_EXPANDER_SQUARE and CTREE_EXPANDER_TRIANGLE
GTK.Ctree set_indent(int npixels)
Set the indentation level
GTK.Ctree set_line_style(int style)
Set the line style, one of CTREE_LINES_DOTTED , CTREE_LINES_NONE , CTREE_LINES_SOLID and CTREE_LINES_TABBED
GTK.Ctree set_node_info(GTK.CTreeNode node, string text, int spacing, GDK.Pixmap pixmap_closed, GDK.Bitmap mask_closed, GDK.Pixmap pixmap_opened, GDK.Bitmap mask_opened, int is_leaf, int expanded)
|
GTK.Ctree set_show_stub(int stubp)
If true, the 'stub' will be shown. The stub is the small line that goes horizontally from the expand or collapse button to the actual contents of the tree
GTK.Ctree set_spacing(int npixels)
Set the spacing between the tree column and the other columns
GTK.Ctree sort_node(GTK.CTreeNode node)
Sort the specified node.
GTK.Ctree sort_recursive(GTK.CTreeNode node)
Sort the specified node and it's children.
GTK.Ctree toggle_expansion(GTK.CTreeNode node)
If the node is expanded, collapse it, and if it's collapsed, expand it.
GTK.Ctree toggle_expansion_recursive(GTK.CTreeNode node)
Toggle the expansion of the whole subtree, starting with node.
GTK.Ctree unselect(GTK.CTreeNode node)
Unselect a node.
GTK.Ctree unselect_recursive(GTK.CTreeNode node)
Unselect a node and it's children.
| CLASS GTK.Scrollbar |
These are your standard, run-of-the-mill scrollbars. These should be used only for scrolling some other widget, such as a list, a text box, or a viewport (and it's generally easier to use the scrolled window widget in most cases). For other purposes, you should use scale widgets, as they are friendlier and more featureful.
inherit GTK.Range : Range
| CLASS GTK.EventBox |
Some gtk widgets don't have associated X windows, so they just draw on their parents. Because of this, they cannot receive events and if they are incorrectly sized, they don't clip so you can get messy overwritting etc. If you require more from these widgets, the EventBox is for you.
At first glance, the EventBox widget might appear to be totally useless. It draws nothing on the screen and responds to no events. However, it does serve a function - it provides an X window for its child widget. This is important as many GTK widgets do not have an associated X window. Not having an X window saves memory and improves performance, but also has some drawbacks. A widget without an X window cannot receive events, and does not perform any clipping on it's contents. Although the name EventBox emphasizes the event-handling function, the widget can also be used for clipping.
The primary use for this widget is when you want to receive events for a widget without a window. Examples of such widgets are labels and images.
GTK.EventBox()->set_usize(100,100)

inherit GTK.Bin : Bin
GTK.EventBox GTK.EventBox()
Create a new event box widget
| CLASS GTK.Separator |
A generic separator. Basicaly a line, like <hr> in HTML.
inherit GTK.Widget : Widget
| CLASS GTK.ButtonBox |
More or less equivalent to a normal box, but you can set a few layout schemes that are not available for normal boxes. See the hbox and vbox documentation for examples.
inherit GTK.Box : Box
mapping get_child_ipadding()
Return the default inter-child padding ([ "x":xpadding, "y":ypadding ])
mapping get_child_size()
Return the child size as ([ "x":xsize, "y":ysize ])
int get_layout()
Returns the currently configured layout. One of BUTTONBOX_DEFAULT_STYLE , BUTTONBOX_EDGE , BUTTONBOX_END , BUTTONBOX_SPREAD and BUTTONBOX_START
int get_spacing()
Return the spacing that is added between the buttons
GTK.ButtonBox set_child_ipadding(int child_number, int child_padding)
Set the padding for a specific child.
GTK.ButtonBox set_child_size(int child_number, int child_size)
Set the size of a specified child
GTK.ButtonBox set_layout(int layout)
layout is one of BUTTONBOX_DEFAULT_STYLE , BUTTONBOX_EDGE , BUTTONBOX_END , BUTTONBOX_SPREAD and BUTTONBOX_START
GTK.ButtonBox set_spacing(int spacing)
in pixels
| CLASS GTK.ToggleButton |
Toggle buttons are derived from normal buttons and are very similar, except they will always be in one of two states, alternated by a click. They may be depressed, and when you click again, they will pop back up. Click again, and they will pop back down.
GTK.ToggleButton("Toggle button")
![]()
GTK.ToggleButton("Toggle button")->set_active( 1 )
![]()
Signals: toggled
inherit GTK.Button : Button
GTK.ToggleButton GTK.ToggleButton(string|void label)
If you supply a string, a label will be created and inserted in the button. Otherwise, use ->add(widget) to create the contents of the button.
int get_active()
returns 1 if the button is pressed, 0 otherwise.
GTK.ToggleButton set_active(int activep)
If activep is true, the toggle button will be activated.
GTK.ToggleButton set_mode(int mode)
If true, draw indicator
GTK.ToggleButton toggled()
emulate a 'toggle' of the button. This will emit a 'toggled' signal.
| CLASS GTK.Combo |
Thee combo box is another fairly simple widget that is really just a collection of other widgets. From the user's point of view, the widget consists of a text entry box and a pull down menu from which the user can select one of a set of predefined entries. Alternatively, the user can type a different option directly into the text box.
The combo box has two principal parts that you as the programmer really care about: The W(entry) and the W(list).
GTK.Combo()
![]()
inherit GTK.Hbox : Hbox
GTK.Combo GTK.Combo()
Create a new combo box
GTK.Combo disable_activate()
This will disable the 'activate' signal for the entry widget in the combo box.
GTK.Entry get_entry()
The entry widget
GTK.Combo set_case_sensitive(int sensitivep)
set_case_sensitive() toggles whether or not GTK searches for entries in a case sensitive manner. This is used when the Combo widget is asked to find a value from the list using the current entry in the text box. This completion can be performed in either a case sensitive or insensitive manner, depending upon the use of this function. The Combo widget can also simply complete the current entry if the user presses the key combination MOD-1 and "Tab". MOD-1 is often mapped to the "Alt" key, by the xmodmap utility. Note, however that some window managers also use this key combination, which will override its use within GTK.
GTK.Combo set_item_string(GTK.Item item, string text)
The item is one of the ones in the list subwidget.
GTK.Combo set_popdown_strings(array strings)
Set the values in the popdown list.
GTK.Combo set_use_arrows(int use_arrows)
set_use_arrows() lets the user change the value in the entry using the up/down arrow keys. This doesn't bring up the list, but rather replaces the current text in the entry with the next list entry (up or down, as your key choice indicates). It does this by searching in the list for the item corresponding to the current value in the entry and selecting the previous/next item accordingly. Usually in an entry the arrow keys are used to change focus (you can do that anyway using TAB). Note that when the current item is the last of the list and you press arrow-down it changes the focus (the same applies with the first item and arrow-up).
GTK.Combo set_use_arrows_always(int always_arrows)
set_use_arrows_always() allows the use the the up/down arrow keys to cycle through the choices in the dropdown list, just as with set_use_arrows, but it wraps around the values in the list, completely disabling the use of the up and down arrow keys for changing focus.
GTK.Combo set_value_in_list(int value_must_be_in_list, int ok_if_empty)
If value_must_be_in_list is true, the user will not be able to enter any value that is not in the list. If ok_if_empty is true, empty values are possible as well as the values in the list.
| CLASS GTK.Table |
The Gtk.Table allow the programmer to arrange widgets in rows and columns, making it easy to align many widgets next to each other, horizontally and vertically.
GTK.Table(2,2,0)->attach_defaults( GTK.Label("0,0"), 0, 1, 0, 1)->attach_defaults( GTK.Label("0,1"), 0, 1, 1, 2)->attach_defaults( GTK.Label("1,0"), 1, 2, 0, 1)->attach_defaults( GTK.Label("1,1"), 1, 2, 1, 2)->set_col_spacings(10)->set_row_spacings(10)
![]()
GTK.Table(2,2,0)->attach_defaults( GTK.Label("0,0-1,0"), 0, 2, 0, 1)->attach_defaults( GTK.Label("0,1"), 0, 1, 1, 2)->attach_defaults( GTK.Label("1,1"), 1, 2, 1, 2)->set_col_spacings(10)->set_row_spacings(10)
![]()
inherit GTK.Container : Container
GTK.Table attach(GTK.Widget subwidget, int left, int right, int top, int bottom, int xoptions, int yoptions, int xpad, int ypad)
The left and right attach arguments specify where to place the widget, and how many boxes to use. If you want a button in the lower right table entry of our 2x2 table, and want it to fill that entry ONLY. left_attach would be = 1, right_attach = 2, top_attach = 1, bottom_attach = 2.
Now, if you wanted a widget to take up the whole top row of our 2x2 table, you'd use left_attach = 0, right_attach = 2, top_attach = 0, bottom_attach = 1.
The xoptions and yoptions are used to specify packing options and may be OR'ed together to allow multiple options.
These options are: <ul> <li> GTK.Fill - If the table box is larger than the widget, and GTK_FILL is specified, the widget will expand to use all the room available.</li> <li> GTK.Shrink - If the table widget was allocated less space then was requested (usually by the user resizing the window), then the widgets would normally just be pushed off the bottom of the window and disappear. If GTK_SHRINK is specified, the widgets will shrink with the table.</li> <li> GTK.Expand - This will cause the table cell to expand to use up any remaining space in the window.</li> </ul>
Padding is just like in boxes, creating a clear area around the widget specified in pixels
GTK.Table attach_defaults(GTK.Widget subwidget, int left, int right, int top, int bottom)
As there are many options associated with attach(), this convenience function provides the programmer with a means to add children to a table with identical padding and expansion options.
xoptions, yoptions, xpadding and ypadding are all set the their default values. For the options that is GTK.Fill|GTK.Expand. For the padding it is 0.
GTK.Table GTK.Table(int width, int height, int homogeneousp)
Used to create a new table widget. An initial size must be given by specifying how many rows and columns the table should have, although this can be changed later with resize().
There can never be more than 65535 colums nor more than 65535 rows.
setting homogeneousp to 1 forces the all tablecells to be exactly the same size.
int get_column_spacing()
The spacing between all columns, in pixels.
int get_homogeneous()
If 1, all cells have exactly the same size
int get_ncols()
The number of columns. Between 1 and 65535.
int get_nrows()
The number of rows. Between 1 and 65535.
int get_row_spacing()
The spacing between all rows, in pixels.
GTK.Table resize(int rows, int columns)
If you need to change a table's size after it has been created, this function allows you to do so.
GTK.Table set_col_spacing(int x, int spacing)
alters the amount of space between a given table column and the adjacent columns.
GTK.Table set_col_spacings(int spacing)
Sets the space between every column in the table equal to spacing.
GTK.Table set_homogeneous(int homogeneousp)
Set the homogeneous flag.
GTK.Table set_row_spacing(int y, int spacing)
alters the amount of space between a given table row and the adjacent rows.
GTK.Table set_row_spacings(int spacing)
Sets the space between every row in the table equal to spacing.
| CLASS GTK.Data |
A class inherited by all objects used to store data (they are not widgets)
Signals: disconnect
inherit GTK.Object : Object
| CLASS GTK.Entry |
Use this widget when you want the user to input a single line of text.
GTK.Entry()->set_text("Hello world")->set_editable(1)
![]()
inherit GTK.Editable : Editable
GTK.Entry append_text(string text)
Append the specified string at the end of the entry
GTK.Entry GTK.Entry()
string get_text()
Returns the contents of the entry widget.
GTK.Entry prepend_text(string text)
Prepend the specified string to the start of the entry
GTK.Entry set_max_length(int maxlen)
text is truncated if needed
GTK.Entry set_text(string text)
Set the text to the specified string. The old text is dropped.
GTK.Entry set_visibility(int visiblep)
0 indicates invisible text (password boxes, as an example)
| CLASS GTK.Style |
GTK.Style apply_default_background(GDK.Window window, int set_bgp, int state_type, GDK.Rectangle area, int x, int y, int width, int height)
Set the background of the specified window (or the subarea indicated by the rectangle) to the default background for the state specified by state_type.
If set_bgp is true, the background of the widget will be set, otherwise it will only be drawn into the window.
GTK.Style attach(GDK.Window to)
Attach a style to a window; this process allocates the colors and creates the GC's for the style - it specializes it to a particular visual and colormap. The process may involve the creation of a new style if the style has already been attached to a window with a different style and colormap.
GTK.Style copy()
Copy this style, and return the new style object
GTK.Style destroy()
GTK.Style detach()
Undo a previous attach
array get_base()
array get_base_gc()
array get_bg()
array get_bg_gc()
array get_bg_pixmap()
GDK.Color get_black()
GDK.GC get_black_gc()
array get_dark()
array get_dark_gc()
array get_fg()
array get_fg_gc()
GDK.Font get_font()
array get_light()
array get_light_gc()
array get_mid()
array get_mid_gc()
array get_text()
array get_text_gc()
GDK.Color get_white()
GDK.GC get_white_gc()
| CLASS GTK.Pixmap |
Pixmaps are data structures that contain pictures. These pictures can be used in various places, but most visibly as icons on the X-Windows desktop, or as cursors. A bitmap is a 2-color pixmap.
To use pixmaps in GTK, you must first build a GDK.Pixmap object using GDK.Pixmap.
The pixels in a GTK.Pixmap cannot be manipulated by the application after creation, since under the X Window system the pixel data is stored on the X server and so is not available to the client application. If you want to create graphical images which can be manipulated by the application, look at W(Image).
GTK.Pixmap( GDK.Pixmap( Image.Image(100,100)->test()) )

GTK.Pixmap( GDK.Pixmap( Image.Image(100,100)->test()), GDK.Bitmap(Image.Image(100,100,255,255,255)->box(10,10,80,80, 0,0,0) ))

inherit GTK.Misc : Misc
GTK.Pixmap GTK.Pixmap(GDK.Pixmap pixmap, GDK.Bitmap mask)
Create a new pixmap object, and sets the image and the mask.
mapping get()
Returns ([ "pixmap":pixmap, "mask":mask, "pixmap_insensitive":insensitive version of the pixmap ])
int get_build_insensitive()
GTK.Pixmap set(GDK.Pixmap pixmap, GDK.Bitmap mask)
Sets the GDK.Pixmap image and the optinal GDK.Bitmap mask
GTK.Pixmap set_build_insensitive(int buildp)
Set to TRUE if an extra pixmap should be automatically created to use when the pixmap is insensitive.
GTK.Pixmap set_insensitive_pixmap(GDK.Pixmap insensitive_pixmap)
Set the pixmap to use when the pixmap is insensitive.
| CLASS GTK.GladeXML |
Glade is a free GUI builder for GTK+ and Gnome. It's normally used to create C-code, but can also produce code for other languages. Libglade is a utility library that builds the GUI from the Glade XML save files. This module uses libglade and allows you to easily make GUI designs to be used with your Pike applications. Since PiGTK doesn't support Gnome yet, you can only use the normal GTK widgets.
GTK.Widget get_widget(string name)
This function is used to get get the widget corresponding to name in the interface description. You would use this if you have to do anything to the widget after loading.
GTK.Widget get_widget_by_long_name(string long_name)
This function is used to get the widget corresponding to long_name in the interface description. You would use this if you have to do anything to the widget after loading. This function differs from GladeXML->get_widget, in that you have to give the long form of the widget name, with all its parent widget names, separated by periods.
string get_widget_long_name(GTK.Widget widget)
Used to get the long name of a widget that was generated by a GladeXML object.
string get_widget_name(GTK.Widget widget)
Used to get the name of a widget that was generated by a GladeXML object.
GTK.GladeXML new(string filename, string|void root, string|void domain)
Creates a new GladeXML object (and the corresponding widgets) from the XML file filename. Optionally it will only build the interface from the widget node root. This feature is useful if you only want to build say a toolbar or menu from the XML file, but not the window it is embedded in. Note also that the XML parse tree is cached to speed up creating another GladeXML object for the same file. The third optional argument is used to specify a different translation domain from the default to be used.
GTK.GladeXML new_from_memory(string data, string|void root, string|void domain)
Creates a new GladeXML object (and the corresponding widgets) from the string data. Optionally it will only build the interface from the widget node root. This feature is useful if you only want to build say a toolbar or menu from the XML document, but not the window it is embedded in. The third optional argument is used to specify a different translation domain from the default to be used.
GTK.GladeXML signal_autoconnect(mapping callbacks, mixed data)
Try to connect functions to all signals in the interface. The mapping should consist of handler name : function pairs. The data argument will be saved and sent as the first argument to all callback functions.
GTK.GladeXML signal_autoconnect_new(mapping callbacks, mixed data)
Try to connect functions to all signals in the interface. The mapping should consist of handler name : function pairs. This function differs from the signal_connect function in how it calls the callback function.
The old interface:
void signal_handler( mixed data, GTK.Object object,
mixed ... signal_arguments )
The new interface:
void signal_handler( mixed ... signal_arguments,
mixed data, GTK.Object object )
| CLASS GTK.Alignment |
The W(Alignment) widget controls the alignment and size of its child widget. It has four settings: xscale, yscale, xalign, and yalign.
The scale settings are used to specify how much the child widget should expand to fill the space allocated to the W(Alignment). The values can range from 0 (meaning the child doesn't expand at all) to 1 (meaning the child expands to fill all of the available space).
The align settings are used to place the child widget within the available area. The values range from 0 (top or left) to 1 (bottom or right). Of course, if the scale settings are both set to 1, the alignment settings have no effect.
NOIMG
inherit GTK.Bin : Bin
GTK.Alignment GTK.Alignment(float xalign, float yalign, float xscale, float yscale)
|
float get_xalign()
the horizontal alignment of the child widget, from 0 (left) to 1 (right).
float get_xscale()
the amount that the child widget expands horizontally to fill up unused space, from 0 to 1. A value of 0 indicates that the child widget should never expand. A value of 1 indicates that the child widget will expand to fill all of the space allocated for the GTK.Alignment.
float get_yalign()
the vertical alignment of the child widget, from 0 (top) to 1 (bottom).
float get_yscale()
the amount that the child widget expands vertically to fill up unused space, from 0 to 1. The values are similar to xscale.
GTK.Alignment set(float xalign, float yalign, float xscale, float yscale)
|
| CLASS GTK.OptionMenu |
A OptionMenu is a widget that allows the user to choose from a list of valid choices. The OptionMenu displays the selected choice. When activated the OptionMenu displays a popup W(Menu) which allows the user to make a new choice.
GTK.OptionMenu()->set_menu(GTK.Menu()->add( GTK.Menu_item("Option 1") ));
![]()
inherit GTK.Button : Button
GTK.OptionMenu GTK.OptionMenu()
Create a new option menu widget
GTK.Menu get_menu()
Returns the W(Menu) associated with the OptionMenu.
GTK.OptionMenu remove_menu()
Remove the menu.
GTK.OptionMenu set_history(int index)
Selects the menu item specified by index making it the newly selected value for the option menu.
GTK.OptionMenu set_menu(GTK.Menu menu)
Provides the GtkMenu that is popped up to allow the user to choose a new value. You should provide a simple menu avoiding the use of tearoff menu items, submenus, and accelerators.
| CLASS GTK.Vscrollbar |
General documentation: See W(Scrollbar)
GTK.Vscrollbar(GTK.Adjustment())->set_usize(15,60)
![]()
inherit GTK.Scrollbar : Scrollbar
GTK.Vscrollbar GTK.Vscrollbar(GTK.Adjustment pos)
Used to create a new vscrollbar widget. The adjustment argument can either be an existing W(Adjustment), or 0, in which case one will be created for you. Specifying 0 might actually be useful in this case, if you wish to pass the newly automatically created adjustment to the constructor function of some other widget which will configure it for you, such as a text widget.
| CLASS GTK.TipsQuery |
inherit GTK.Label : Label
GTK.TipsQuery GTK.TipsQuery()
GTK.Widget get_caller()
int get_in_query()
string get_label_inactive()
string get_label_no_tip()
GTK.Widget get_last_crossed()
GTK.TipsQuery set_caller(GTK.Widget caller_widget)
GTK.TipsQuery set_labels(string label_inactive, string label_no_tip)
GTK.TipsQuery start_query()
GTK.TipsQuery stop_query()
| CLASS GTK.Frame |
The frame widget is a Bin that surrounds its child with a decorative frame and an optional label. If present, the label is drawn in a gap in the top side of the frame. The position of the label can be controlled with set_label_align().
Used to visually group objects.
GTK.Frame("Title")->add(GTK.Label("Contents"))
![]()
GTK.Frame()->add(GTK.Label("Contents"))
![]()
GTK.Frame()->add(GTK.Label("Contents"))->set_shadow_type(GTK.SHADOW_IN)
![]()
inherit GTK.Container : Container
GTK.Frame GTK.Frame(string|void label_text)
Create a new W(Frame) widget.
GTK.Frame set_label(string|void label_text)
Set the text of the label.
GTK.Frame set_label_align(float xalign, float yalign)
Arguments are xalignment and yalignment. 0.0 is left or topmost, 1.0 is right or bottommost. The default value for a newly created Frame is 0.0.
GTK.Frame set_shadow_type(int shadow_type)
Set the shadow type for the Frame widget. The type is one of SHADOW_ETCHED_IN , SHADOW_ETCHED_OUT , SHADOW_IN , SHADOW_NONE and SHADOW_OUT
| CLASS GTK.CheckMenuItem |
A check menu item is more or less identical to a check button, but it
should be used in menus.
GTK.CheckMenuItem("Hi there")
![]()
GTK.CheckMenuItem("Hi there")->set_active(1)
![]()
Signals: toggled Called when the state of the menu item is changed
inherit GTK.MenuItem : MenuItem
GTK.CheckMenuItem GTK.CheckMenuItem(string|void label)
The argument, if specified, is the label of the item. If no label is specified, use object->add() to add some other widget (such as an pixmap or image widget)
GTK.CheckMenuItem set_active(int new_state)
State is either 1 or 0. If 1, the button will be 'pressed'.
GTK.CheckMenuItem set_show_toggle(int togglep)
If true, the toggle indicator will be shown
GTK.CheckMenuItem toggled()
Emulate a toggled event
| CLASS GTK.Vbox |
Most packing is done by creating boxes. These are invisible widget containers that we can pack our widgets into which come in two forms, a horizontal box, and a vertical box. This is the vertical one. When packing widgets into a vertical box, the objects are inserted horizontally from top to bottom or bottom to top depending on the call used.
GTK.Vbox(0,0)->add(GTK.Button("Hello"))->add(GTK.Button("World"))->pack_end_defaults(GTK.Button("From right"))->pack_start_defaults(GTK.Button("From left"))

GTK.Vbox(1,0)->add(GTK.Button("Hello"))->add(GTK.Button("World"))->pack_end_defaults(GTK.Button("From right"))->pack_start_defaults(GTK.Button("From left"))

GTK.Vbox(1,40)->add(GTK.Button("Hello"))->add(GTK.Button("World"))->pack_end_defaults(GTK.Button("From right"))->pack_start_defaults(GTK.Button("From left"))

inherit GTK.Box : Box
GTK.Vbox GTK.Vbox(int uniformp, int padding)
Create a new horizontal box widget. If all_same_size is true, all widgets will have exactly the same size. padding is added to the top and bottom of the children.
| CLASS GTK.Clock |
The GtkClock widget provides an easy way of providing a textual clock in your application. It supports realtime display, as well as count up and count down modes. The clock widget could conceivably be used in such applications as an application's status bar, or as the basis for a panel applet, etc.
Three modes of operation are supported. These are realtime - which displays the current time, count-up/increasing - which counts up from an initial value (like a stopwatch), and count-down/decreasing - which counts down from an initial value.
Note, however, that the accuracy of the gtkclock widget is limited
to 1 second.
GTK.Clock( GTK.ClockRealtime );
![]()
GTK.Clock( GTK.ClockDecreasing )->set_seconds(10000)->start();
![]()
inherit GTK.Label : Label
GTK.Clock GTK.Clock(int type)
type is one of CLOCK_DECREASING , CLOCK_INCREASING and CLOCK_REALTIME ;
GTK.Clock set_format(string fmt)
Set the format of a GtkClock widget. The syntax of the format string is identical to that of the function strftime(3). Further information about time format strings can be found on this man page. The widget defaults to a format string of "%H:%M" in realtime mode, or "%H:%M:%S" in count-up or count-down modes.
GTK.Clock set_seconds(int seconds)
Set the current time as displayed by the clock in count-up and count-down modes. This function has no effect in realtime mode, as the clock time is determined by the system clock in realtime mode.
GTK.Clock set_update_interval(int seconds)
Set the interval at which the GtkClock widget is updated. The seconds parameter is used to determine how often the time shown on the widget is updated. The default value is to update every second, but you may wish to increase this value. If you set the update interval to 0, the clock is never updated.
GTK.Clock start()
Start the clock counting in count-up or count-down modes. The clock will begin counting up or down from the time when this function is called, until gtk_clock_stop is called. This function has no effect in the realtime mode (you can't start and stop real time! :-).
GTK.Clock stop()
Stop the clock counting in count-up or count-down modes. The clock ceases counting up or down, and the last time reached remains on the display. This function has no effect in the realtime mode (you can't start and stop real time! :-).
| CLASS GTK.ColorSelection |
The color selection widget is, not surprisingly, a widget for interactive selection of colors. This composite widget lets the user select a color by manipulating RGB (Red, Green, Blue) and HSV (Hue, Saturation, Value) triples. This is done either by adjusting single values with sliders or entries, or by picking the desired color from a hue-saturation wheel/value bar. Optionally, the opacity of the color can also be set.
The color selection widget currently emits only one signal, "color_changed", which is emitted whenever the current color in the widget changes, either when the user changes it or if it's set explicitly through set_color().
GTK.ColorSelection()

inherit GTK.Vbox : Vbox
GTK.ColorSelection GTK.ColorSelection()
Create a new color selection.
array get_color()
When you need to query the current color, typically when you've received a "color_changed" signal, you use this function. The return value is an array of floats, See the set_color() function for the description of this array.
GTK.ColorSelection set_color(array color)
You can set the current color explicitly by calling this function with an array of colors (floats). The length of the array depends on whether opacity is enabled or not. Position 0 contains the red component, 1 is green, 2 is blue and opacity is at position 3 (only if opacity is enabled, see set_opacity()) All values are between 0.0 and 1.0
GTK.ColorSelection set_update_policy(int policy)
one of UPDATE_ALWAYS , UPDATE_CONTINUOUS , UPDATE_DELAYED , UPDATE_DISCONTINUOUS and UPDATE_IF_VALID .
The default policy is GTK.UpdateContinuous which means that the current color is updated continuously when the user drags the sliders or presses the mouse and drags in the hue-saturation wheel or value bar. If you experience performance problems, you may want to set the policy to GTK.UpdateDiscontinuous or GTK.UpdateDelayed.
| CLASS GTK.FontSelection |
GTK.FontSelection()

inherit GTK.Notebook : Notebook
GTK.FontSelection GTK.FontSelection()
GDK.Font get_font()
string get_font_name()
string get_preview_text()
GTK.FontSelection set_font_name(string xlfd)
This sets the currently displayed font. It should be a valid X Logical Font Description font name (anything else will be ignored), e.g. "-adobe-courier-bold-o-normal--25-*-*-*-*-*-*-*"
GTK.FontSelection set_preview_text(string text)
| CLASS GTK.Vseparator |
Simply creates a vertical separator. No bells or whistles.
GTK.Vseparator()->set_usize(3,50)
![]()
inherit GTK.Separator : Separator
GTK.Vseparator GTK.Vseparator()
Used to create a new vseparator widget.
| CLASS GTK.PixmapMenuItem |
GtkPixmapMenuItem works like a normal GTK menu item, but you can insert a arbitrary widget (most often a pixmap widget), which is displayed at the left side. The advantage is that indentation is handled the same way as GTK does (i.e if you create a menu with a gtk_check_menu_item, all normal menu items are automatically indented by GTK - so if you use a normal menu item to display pixmaps at the left side, the pixmaps will be indented, which is not what you want. This widget solves the problem).
inherit GTK.MenuItem : MenuItem
GTK.PixmapMenuItem GTK.PixmapMenuItem()
Creates a new pixmap menu item.
GTK.PixmapMenuItem set_pixmap(GTK.Widget pixmap)
Set the pixmap of the menu item.
| CLASS GTK.Button |
A container that can only contain one child, and accepts events.
draws a bevelbox around itself.
GTK.Button("A button")
![]()
GTK.Button("A button\nwith multiple lines\nof text")
![]()
GTK.Button()->add(GTK.Image(GDK.Image(0)->set(Image.Image(100,40)->test())))
![]()
Signals: clicked Called when the button is pressed, and then released
enter Called when the mouse enters the button
leave Called when the mouse leaves the button
pressed Called when the button is pressed
released Called when the button is released
inherit GTK.Container : Container
GTK.Button clicked()
Emulate a 'clicked' event (press followed by release).
GTK.Button GTK.Button(string|void label_text)
If a string is supplied, a W(Label) is created and added to the button.
GTK.Button enter()
Emulate a 'enter' event.
GTK.Widget get_child()
The (one and only) child of this container.
int get_relief()
One of RELIEF_HALF , RELIEF_NONE and RELIEF_NORMAL , set with set_relief()
GTK.Button leave()
Emulate a 'leave' event.
GTK.Button pressed()
Emulate a 'press' event.
GTK.Button released()
Emulate a 'release' event.
GTK.Button set_relief(int newstyle)
One of RELIEF_HALF , RELIEF_NONE and RELIEF_NORMAL
| Module Bz2 |
The Bz2 module contains functions to compress and uncompress strings using the same algorithm as the program bzip2. Compressing and decompressing can be done in streaming mode feeding the compress and decompress objects with arbitrarily large pieces of data. The Bz2 module consists of three classes; Bz2.Deflate,Bz2.Inflate. and Bz2.File Bz2.Deflate is used to compress data and Bz2.Inflate is used to uncompress data. (Think "inflatable boat") Bz2.File is used to handle Bzip2 files.
Note that this module is only available if libbzip2 was available when Pike was compiled.
Note that although the functions in Inflate and Deflate use the same algorithm as bzip2, they do not use the exact same format, so you can not directly zip files or unzip zip-files using those functions. That is why there exists a third class for files.
| CLASS Bz2.Deflate |
Bz2.Deflate is a builtin program written in C. It interfaces the packing routines in the bzlib library.
This program is only available if libz was available and found when Pike was compiled.
Bz2.Inflate()
void Bz2.Deflate(int(1..9)|void block_size)
If given, block_size should be a number from 1 to 9 indicating the block size used when doing compression. The actual block size will be a 100000 times this number. Low numbers are considered 'fast', higher numbers are considered 'slow' but give better packing. The parameter is set to 9 if it is omitted.
This function can also be used to re-initialize a Bz2.Deflate object so it can be re-used.
void feed(string data)
This function feeds the data to the internal buffers of the Deflate object. All data is buffered until a read or a finish is done.
Bz2.Deflate->read() Bz2.Deflate->finish()
string read(string data)
This function feeds the data to the internal buffers of the Deflate object. Then it compresses all buffered data and returns the compressed data as a string
Bz2.Deflate->feed() Bz2.Deflate->finish()
string finish(string data)
This method feeds the data to the internal buffers of the Deflate object. Then it compresses all buffered data adds a end of data marker ot it, returns the compressed data as a string, and reinitializes the deflate object.
Bz2.Deflate->feed() Bz2.Deflate->read()
string deflate(string data, int(0..2)|void flush_mode)
This function performs bzip2 style compression on a string data and returns the packed data. Streaming can be done by calling this function several times and concatenating the returned data.
The optional argument flush_mode should be one of the following:
|
Bz2.Inflate->inflate()
| CLASS Bz2.Inflate |
Bz2.Inflate is a builtin program written in C. It interfaces the unpacking routines in the libz library.
This program is only available if bzlib was available and found when Pike was compiled.
Deflate
void Bz2.Inflate()
string inflate(string data)
This function performs bzip2 style decompression. It can do decompression with arbitrarily large pieces of data. When fed with data, it decompresses as much as it can and buffers the rest.
while(..){ foo = compressed_data[i..i+9]; uncompressed_concatenated_data += inflate_object->inflate(foo); i = i+10; }
Bz2.Deflate->deflate()
| CLASS Bz2.File |
Low-level implementation of read/write support for Bzip2 files
This class is currently not available on Windows.
int(0..1) close()
closes the file
void Bz2.File()
Creates a Bz2.File object
int(0..1) read_open(string file)
Opens a file for reading.
The name of the file to be opened
int(0..1) write_open(string file)
Opens a file for writing.
The name of the file to be opened
int(0..1) open(string file, void|string mode)
Opens a file for I/O.
The name of the file to be opened
Mode for the file operations. Can be either "r" (read) or "w". Read is default.
int write(string data)
Writes the data to the file.
the number of bytes written to the file.
int|string read(int len)
Reads len (uncompressed) bytes from the file. If len is omitted the whole file is read. If read is unsuccessful, 0 is returned.
int(0..1) eof()
1 if EOF has been reached, 0 otherwise
| Module SDL |
SDL or Simple DirectMedia Layer is a cross-platform multimedia library designed to provide fast access to the graphics framebuffer, audio device, input and other devices. This module implements a wrapper for SDL and other relevant libraries like SDL_mixer. The interface is similar to the C one, but using generally accepted Pike syntax.
This means that classes are used when appropriate and that method names use all lowercase letters with words separated by _. For example SDL_SetVideoMode is named SDL.set_video_mode. Also note that unless otherwise noted, errors result in an error being thrown rather than returning -1 or 0, as commonly done in SDL methods.
void init(int flags)
Initializes SDL. This should be called before all other SDL functions.
The flags parameter specifies what part(s) of SDL to initialize. It can be one of many of the following ORed together.
Initializes the timer subsystem.
Initializes the audio subsystem.
Initializes the video subsystem.
Initializes the cdrom subsystem.
Initializes the joystick subsystem.
Initialize all of the above.
Prevents SDL from catching fatal signals.
Run event polling in a separate thread. Not always supported.
SDL.quit() , SDL.init_sub_system() , SDL.quit_sub_system()
void|string get_error()
Get the last internal SDL error.
The error string, or zero if there was no error.
void init_sub_system(int flags)
After SDL has been initialized with init() you may initialize uninitialized subsystems with this method.
The same as what is used in SDL.init() .
void init_sub_system(int flags)
After SDL has been initialized with SDL.init() you may initialize uninitialized subsystems with this method.
a bitwise OR'd combination of the subsystems you wish to check (see SDL.init() for a list of subsystem flags).
SDL.init() , SDL.quit() , SDL.quit_sub_system()
int was_init(int flags)
This method allows you to see which SDL subsytems have been initialized.
a bitwise OR'd combination of the subsystems you wish to check (see SDL.init() for a list of subsystem flags).
a bitwised OR'd combination of the initialized subsystems
SDL.init() , SDL.init_sub_system()
void quit()
Shuts down all SDL subsystems and frees the resources allocated to them. This should always be called before you exit.
You can use the atexit() method to ensure that this method is always called when Pike exits normally.
SDL.init() , SDL.init_sub_system() , SDL.quit_sub_system()
int enable_unicode(int enable)
Enables/Disables UNICODE keyboard translation.
If you wish to translate a keysym to it's printable representation, you need to enable UNICODE translation using this function and then look in the unicode member of the SDL.Keysym class. This value will be zero for keysyms that do not have a printable representation. UNICODE translation is disabled by default as the conversion can cause a slight overhead.
A value of 1 enables Unicode translation, 0 disables it and -1 leaves it unchanged (useful for querying the current translation mode).
The previous translation mode (1 enabled, 0 disabled). If enable is -1, the return value is the current translation mode.
SDL.Keysym
int get_mod_state()
Returns the current state of the modifier keys (CTRL, ALT, etc.).
The return value can be an OR'd combination of the following: SDL.KMOD_NONE, SDL.KMOD_LSHIFT, SDL.KMOD_RSHIFT, SDL.KMOD_LCTRL, SDL.KMOD_RCTRL, SDL.KMOD_LALT, SDL.KMOD_RALT, SDL.KMOD_LMETA, SDL.KMOD_RMETA, SDL.KMOD_NUM, SDL.KMOD_CAPS, and SDL.KMOD_MODE. For convenience the following are also defined: SDL.KMOD_CTRL, SDL.KMOD_SHIFT, SDL.KMOD_ALT and SDL.KMOD_META
SDL.get_key_state()
string get_key_state()
Gets a snapshot of the current keyboard state. The current state is return as a string. The string is indexed by the SDL.K_* symbols. A value of 1 means the key is pressed and a value of 0 means its not.
SDL.pump_events() to update the state array.
int video_mode_ok(int width, int height, int bpp, int flags)
Document this function
int flip(SDL.Surface|void screen)
On hardware that supports double-buffering, this function sets up a flip and returns. The hardware will wait for vertical retrace, and then swap video buffers before the next video surface blit or lock will return. On hardware that doesn't support double-buffering, this is equivalent to calling SDL.update_rect(screen, 0, 0, 0, 0)
The SDL.DOUBLEBUF flag must have been passed to SDL_SetVideoMode, when setting the video mode for this function to perform hardware flipping.
The screen object to flip. If missing, the default screen is used.
This function returns 1 if successful, or 0 if there was an error.
SDL.update_rect()
void update_rect(int x, int y, int w, int h, SDL.Surface|void screen)
Makes sure the given area is updated on the given screen. The rectangle must be confined within the screen boundaries (no clipping is done).
If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire screen.
This function should not be called while 'screen' is locked.
Top left corner of the rectangle to update.
Width and height of the rectangle to update.
The screen object to flip. If missing, the default screen is used.
SDL.flip()
int set_gamma(float red, float green, float blue)
Document this function
void|object get_video_surface()
Document this function
void|object get_video_info()
Document this function
void gl_set_attribute(int attribute, int value)
Document this function
void gl_get_attribute(int attribute)
Document this function
int show_cursor(int show)
Document this function
void warp_mouse(int xpos, int ypos)
Document this function
void gl_swap_buffers()
Document this function
object set_video_mode(int width, int height, int bpp, int flags)
Document this function
int blit_surface(SDL.Surface src, SDL.Surface dst, SDL.Rect srcrect, SDL.Rect dstrect)
Document this function
void|string video_driver_name()
Document this function
void set_caption(string title, string icon)
Document this function
array(string) get_caption()
Document this function
int iconify_window()
Document this function
int toggle_fullscreen(void|SDL.Surface screen)
Document this function
int grab_input(int mode)
Document this function
int num_joysticks()
Document this function
string joystick_name(int device_index)
Document this function
int joystick_opened(int device_index)
Document this function
void joystick_update()
Document this function
int joystick_event_state(int state)
Document this function
int cd_num_drivers()
Document this function
string|void cd_name(int drive)
Document this function
void open_audio(int frequency, int format, int channels, int bufsize)
Document this function
| CLASS SDL.Rect |
Used in SDL to define a rectangular area. It is sometimes also used to specify only points or sizes (i.e only one of the position and dimension is used).
int SDL.Rect.x
int SDL.Rect.y
Position of the upper-left corner of the rectangle.
int SDL.Rect.w
int SDL.Rect.h
The width and height of the rectangle.
mixed cast(string type)
It is possible to cast a Rect object to an array or to a mapping. The array will have the values in the x, y, w, h order and the mapping will have the values associated with those names.
| CLASS SDL.Keysym |
The Keysym class is used to report key presses and releases. It's available from the SDL.Event class for keyboard events.
The scancode field should generally be left alone - it is the hardware dependent scancode returned by the keyboard. The sym field is extremely useful. It is the SDL-defined value of the key. This field is very useful when you are checking for certain key presses.
mod stores the current state of the keyboard modifiers as explained in SDL.get_mod_state() . The unicode field is only used when UNICODE translation is enabled with SDL.enable_unicode() . If unicode is non-zero then this a the UNICODE character corresponding to the keypress. If the high 9 bits of the character are 0, then this maps to the equivalent ASCII character.
UNICODE translation does have a slight overhead so don't enable it unless its needed.
int SDL.Keysym.scancode
Hardware specific scancode
int SDL.Keysym.sym
SDL virtual keysym
int SDL.Keysym.mod
Current key modifiers
int SDL.Keysym.unicode
Translated character
| CLASS SDL.PixelFormat |
This describes the format of the pixel data stored at the pixels field of a SDL.Surface . Every surface stores a PixelFormat in the format field.
int SDL.PixelFormat.bits_per_pixel
The number of bits used to represent each pixel in a surface. Usually 8, 16, 24 or 32.
int SDL.PixelFormat.bytes_per_pixel
The number of bytes used to represent each pixel in a surface. Usually one to four.
int SDL.PixelFormat.rmask
int SDL.PixelFormat.gmask
int SDL.PixelFormat.bmask
int SDL.PixelFormat.amask
Binary mask used to retrieve individual color values.
int SDL.PixelFormat.rloss
int SDL.PixelFormat.gloss
int SDL.PixelFormat.bloss
int SDL.PixelFormat.aloss
Precision loss of each color component.
int SDL.PixelFormat.rshift
int SDL.PixelFormat.gshift
int SDL.PixelFormat.bshift
int SDL.PixelFormat.ashift
Binary left shift of each color component in the pixel value.
int SDL.PixelFormat.colorkey
Pixel value of transparent pixels.
int SDL.PixelFormat.alpha
Overall surface alpha value.
array(int) losses()
Convenience method returning the RGBA precision loss as an array.
array(int) masks()
Convenience method returning the RGBA masks as an array.
array(int) shifts()
Convenience method returning the RGBA shifts as an array.
int map_rgb(int r, int g, int b)
int map_rgb(Image.Color.Color color)
Maps the RGB color value to the specified pixel format and returns the pixel value as an integer.
If the format has a palette (8-bit) the index of the closest matching color in the palette will be returned.
If the pixel format has an alpha component it will be returned as all 1 bits (fully opaque).
The red, green and blue components specified as an integer between 0 and 255.
The color as represented by an Image.Color.Color object.
A pixel value best approximating the given RGB color value for a given pixel format.
map_rgba() , get_rgb() , get_rgba()
int map_rgba(int r, int g, int b, int a)
int map_rgba(Image.Color.Color color, int a)
Maps the RGBA color value to the specified pixel format and returns the pixel value as an integer.
If the format has a palette (8-bit) the index of the closest matching color in the palette will be returned.
If the pixel format has an alpha component it will be returned as all 1 bits (fully opaque).
The red, green and blue components specified as an integer between 0 and 255.
The color as represented by an Image.Color.Color object.
A pixel value best approximating the given RGB color value for a given pixel format.
map_rgb() , get_rgb() , get_rgba()
Image.Color.Color get_rgb(int pixel)
Get RGB component values from a pixel stored in this pixel format.
A pixel retrieved from a surface with this pixel format or a color previously mapped with map_rgb() or map_rgba() .
A Image.Color.Color object with the RGB components of the pixel.
map_rgb() , map_rgba() , get_rgba()
mapping(string:Image.Color.Color|int) get_rgba(int pixel)
Get RGB component values from a pixel stored in this pixel format.
A pixel retrieved from a surface with this pixel format or a color previously mapped with map_rgb() or map_rgba() .
A mapping containing with the RGBA components of the pixel as described below.
|
map_rgb() , map_rgba() , get_rgb()
| CLASS SDL.VideoInfo |
This (read-only) class is returned by SDL.get_video_info() . It contains information on either the 'best' available mode (if called before SDL.set_video_mode() ) or the current video mode.
int SDL.VideoInfo.blit_hw_cc
Are hardware to hardware colorkey blits accelerated?
int SDL.VideoInfo.blit_hw_a
Are hardware to hardware alpha blits accelerated?
int SDL.VideoInfo.blit_sw
Are software to hardware blits accelerated?
int SDL.VideoInfo.blit_sw_cc
Are software to hardware colorkey blits accelerated?
int SDL.VideoInfo.blit_sw_a
Are software to hardware alpha blits accelerated?
int SDL.VideoInfo.blit_fill
Are color fills accelerated?
int SDL.VideoInfo.video_mem
Total amount of video memory in KB.
SDL.PixelFormat SDL.VideoInfo.format
Pixel format of the video device.
| CLASS SDL.Surface |
Surface's represent areas of "graphical" memory, memory that can be drawn to. The video framebuffer is returned as a SDL.Surface by SDL.set_video_mode() and SDL.get_video_surface() .
int SDL.Surface.w
int SDL.Surface.h
The width and height of the surface in pixels.
SDL.Rect SDL.Surface.clip_rect
This is the clipping rectangle as set by set_clip_rect() .
int SDL.Surface.flags
The following are supported in the flags field.
Surface is stored in system memory
Surface is stored in video memory
Surface uses asynchronous blits if possible.
Allows any pixel-format (Display surface).
Surface has exclusive palette.
Surface is double buffered (Display surface).
Surface is full screen (Display Sur face).
Surface has an OpenGL context (Display Surface).
Surface supports OpenGL blitting (Display Surface).
Surface is resizable (Display Surface).
Surface blit uses hardware acceleration.
Surface use colorkey blitting.
Colorkey blitting is accelerated with RLE.
Surface blit uses alpha blending.
Surface uses preallocated memory.
SDL.PixelFormat SDL.Surface.format
The pixel format of this surface.
int get_pixel(int x, int y)
Get the value of the specified pixel. The surface needs to be locked before this method can be used.
Pixel coordinate to get.
The value of the specified pixel.
set_pixel() , unlock() , lock()
int set_pixel(int x, int y, int pixel)
Set the value of the specified pixel. The surface needs to be locked before this method can be used.
Pixel coordinate to modify.
Pixel value to set to the specified pixel.
A reference to the surface itself.
get_pixel() , unlock() , lock()
int lock()
This methods locks the surface to allow direct access to the pixels using the get_pixel() and set_pixel() methods. Note that although all surfaces in SDL don't require locking, you still need to call this method to enable the set/get pixel methods. You should unlock the surface when you're doing modifying it.
Calling this method multiple times means that you need to call unlock an equal number of times for the surface to become unlocked.
1 for success or 0 if the surface couldn't be locked.
unlock() , set_pixel() , get_pixel()
void unlock()
Surfaces that were previously locked using lock() must be unlocked with unlock() . Surfaces should be unlocked as soon as possible.
lock()
SDL.Surface init(int flags, int width, int height, int depth, int Rmask, int Gmask, int Bmask, int Amask)
This (re)initializes this surface using the specified parameters. Any previously allocated data will be freed. If depth is 8 bits an empty palette is allocated for the surface, otherwise a 'packed-pixel' SDL.PixelFormat is created using the [RGBA]mask's provided. width and height specifies the desired size of the image. The flags specifies the type of surface that should be created. It is an OR'd combination of the following possible values:
SDL will create the surface in system memory. This improves the performance of pixel level access, however you may not be able to take advantage of some types of hardware blitting.
SDL will attempt to create the surface in video memory. This will allow SDL to take advantage of Video->Video blits (which are often accelerated).
This flag turns on colourkeying for blits from this surface. If SDL.HWSURFACE is also specified and colourkeyed blits are hardware-accelerated, then SDL will attempt to place the surface in video memory. Use set_color_key() to set or clear this flag after surface creation.
This flag turns on alpha-blending for blits from this surface. If SDL.HWSURFACE is also specified and alpha blending blits are hardware-accelerated, then the surface will be placed in video memory if possible. Use set_alpha() to set or clear this flag after surface creation.
If an alpha-channel is specified (that is, if Amask is nonzero), then the SDL.SRCALPHA flag is automatically set. You may remove this flag by calling set_alpha() after surface creation.
A reference to itself.
If this method fails, the surface will become uninitialized.
set_image()
SDL.Surface set_image(Image.Image image, int|void flags)
SDL.Surface set_image(Image.Image image, Image.Image alpha, int|void flags)
This (re)initializes this surface from the Image.Image in image. Any previously allocated data will be freed. If initialization is successful, this surface will use RGBA8888 format. For good blitting performance, it should be converted to the display format using display_format() .
The source image.
Optional alpha channel. In Pike, the alpha channel can have different alpha values for red, green and blue. Since SDL doesn't support this, only the alpha value of the red color is used in the conversion. When this calling convention is used, the surface alpha value of image is ignored.
When present this specifies the type of surface that should be created. It is an OR'd combination of the following possible values:
SDL will create the surface in system memory. This improves the performance of pixel level access, however you may not be able to take advantage of some types of hardware blitting.
SDL will attempt to create the surface in video memory. This will allow SDL to take advantage of Video->Video blits (which are often accelerated).
This flag turns on colourkeying for blits from this surface. If SDL.HWSURFACE is also specified and colourkeyed blits are hardware-accelerated, then SDL will attempt to place the surface in video memory. Use set_color_key() to set or clear this flag after surface creation.
This flag turns on alpha-blending for blits from this surface. If SDL.HWSURFACE is also specified and alpha blending blits are hardware-accelerated, then the surface will be placed in video memory if possible. Note that if this surface has an alpha value specified, this flag is enabled automatically. Use set_alpha() to modify this flag at a later point.
If this method fails, the surface will become uninitialized.
A reference to itself.
init()
SDL.Surface display_format()
This function takes a surface and copies it to a new surface of the pixel format and colors of the video framebuffer, suitable for fast blitting onto the display surface. It calls convert_surface() .
If you want to take advantage of hardware colorkey or alpha blit acceleration, you should set the colorkey and / or alpha value before calling this function.
If you want an alpha channel, see display_format_alpha() .
The new surface. An error is thrown if the conversion fails.
SDL.Surface display_format_alpha()
This function takes a surface and copies it to a new surface of the pixel format and colors of the video framebuffer, suitable for fast blitting onto the display surface. It calls convert_surface() .
If you want to take advantage of hardware colorkey or alpha blit acceleration, you should set the colorkey and / or alpha value before calling this function.
This function can be used to convert a colourkey to an alpha channel, if the SDL.SRCCOLORKEY flag is set on the surface. The generated surface will then be transparent (alpha=0) where the pixels match the colourkey, and opaque (alpha=255) elsewhere.
The new surface. An error is thrown if the conversion fails.
object blit(SDL.Surface dst, SDL.Rect|void srcrect, SDL.Rect|void dstrect)
Document this function
object fill_rect(int color, SDL.Rect dstrect)
Document this function
object fill(int color)
Document this function
object set_color_key(int flag, int key)
Document this function
object set_alpha(int flag, int alpha)
Document this function
object set_clip_rect(SDL.Rect rect)
Document this function
object convert_surface(SDL.PixelFormat fmt, int flags)
Document this function
| CLASS SDL.Joystick |
void SDL.Joystick(int device_index)
Document this function
int index()
Document this function
int num_axes()
Document this function
int num_balls()
Document this function
int num_hats()
Document this function
int num_buttons()
Document this function
float get_axis(int axis)
Document this function
int get_hat(int hat)
Document this function
array(int) get_ball(int ball)
Document this function
int get_button(int button)
Document this function
string name()
Document this function
| CLASS SDL.CDTrack |
int SDL.CDTrack.id
int SDL.CDTrack.length
int SDL.CDTrack.offset
int SDL.CDTrack.type
Document this variable
| CLASS SDL.CD |
void SDL.CD(int drive)
Document this function
int SDL.CD.current_frame
int SDL.CD.current_track
int SDL.CD.id
int SDL.CD.numtracks
Document this variable
CDTrack track(int track)
Document this function
int status()
Document this function
int play(int start, int length)
Document this function
int play_tracks(int start_track, int start_frame, int ntracks, int nframes)
Document this function
int pause()
Document this function
int resume()
Document this function
int stop()
Document this function
int eject()
Document this function
| CLASS SDL.Music |
void SDL.Music(string fname)
Document this function
object pause()
Document this function
object halt()
Document this function
object resume()
Document this function
object rewind()
Document this function
int paused()
Document this function
int playing()
Document this function
int fading()
Document this function
object play(int|void loops)
Document this function
object fade_in(int ms, int|void loops)
Document this function
object fade_out(int ms)
Document this function
float set_volume(float vol)
Document this function
float volume()
Document this function
| CLASS SDL.Event |
int get()
Document this function
int wait()
Document this function
int poll()
Document this function
int SDL.Event.axis
int SDL.Event.ball
int SDL.Event.button
int SDL.Event.code
int SDL.Event.gain
int SDL.Event.h
int SDL.Event.hat
Keysym SDL.Event.keysym
int SDL.Event.state
int SDL.Event.type
int SDL.Event.value
int SDL.Event.w
int SDL.Event.which
int SDL.Event.x
int SDL.Event.xrel
int SDL.Event.y
int SDL.Event.yrel
| Module Image |
Image.Layer lay(array(Image.Layer|mapping) layers)
Image.Layer lay(array(Image.Layer|mapping) layers, int xoffset, int yoffset, int xsize, int ysize)
Combine layers.
a new layer object.
Image.Layer
mapping _decode(string data)
Attempts to decode data as image data. The heuristics has some limited ability to decode macbinary files as well.
array(Image.Layer) decode_layers(string data, mapping|void opt)
Attempts to decode data as image layer data. Additional arguments to the various formats decode_layers method can be passed through opt .
string read_file(string file)
Reads the file file and, if the file is compressed with gzip or bzip, attempts to decompress it by calling gzip and bzip2 in a Process.create_process call.
string load_file(void|object|string file)
Loads in a file, which need not be an image file. If no argument is given the data will be taken from stdin. If a file object is given, it will be read to the end of the file. If a string is given the function will first attempt to load a file with that name, then try to download data with the string as URL. Zero will be returned upon failure.
mapping _load(void|object|string file)
Loads a file with load_file and decodes it with _decode .
Image.Layer load_layer(void|object|string file)
Helper function to load an image layer from a file. If no filename is given, Stdio.stdin is used. The loaded file is decoded with _decode.
array(Image.Layer) load_layers(void|object|string file, mixed|void opts)
Helper function to load all image layers from a file. If no filename is given, Stdio.stdin is used. The loaded file is decoded with decode_layers. Extra arguments to the image types layer decoder, e.g. for XCF files, can be given in the opts mapping.
Image.Image load(void|object|string file)
Helper function to load an image from a file. If no filename is given, Stdio.stdin is used. The loaded file is decoded with _decode.
Image.Image filled_circle(int d)
Image.Image filled_circle(int xd, int yd)
Image.Layer filled_circle_layer(int d)
Image.Layer filled_circle_layer(int xd, int yd)
Image.Layer filled_circle_layer(int d, Image.Color.Color color)
Image.Layer filled_circle_layer(int xd, int yd, Image.Color.Color color)
Image.Layer filled_circle_layer(int d, int r, int g, int b)
Image.Layer filled_circle_layer(int xd, int yd, int r, int g, int b)
Generates a filled circle of the dimensions xd x yd (or d x d). The Image is a white circle on black background; the layer function defaults to a white circle (the background is transparent).
| CLASS Image.Font |
Short technical documentation on a font file: This object adds the text-drawing and -creation capabilities of the Image module.
For simple usage, see write and load .
struct file_head
{
unsigned INT32 cookie; - 0x464f4e54
unsigned INT32 version; - 1
unsigned INT32 chars; - number of chars
unsigned INT32 height; - height of font
unsigned INT32 baseline; - font baseline
unsigned INT32 o[1]; - position of char_head's
} *fh;
struct char_head
{
unsigned INT32 width; - width of this character
unsigned INT32 spacing; - spacing to next character
unsigned char data[1]; - pixmap data (1byte/pixel)
} *ch;
version 2:
On-disk syntax (everything in N.B.O), int is 4 bytes, a byte is 8 bits:
pos
0 int cookie = 'FONT'; or 0x464f4e54
4 int version = 2; 1 was the old version without the last four chars
8 int numchars; Always 256 in this version of the dump program
12 int height; in (whole) pixels
16 int baseline; in (whole) pixels
20 char direction; 1==right to left, 0 is left to right
21 char format; Font format
22 char colortablep; Colortable format
23 char kerningtablep; Kerning table format
24 int offsets[numchars]; pointers into the data, realative to &cookie.
[colortable]
[kerningtable]
At each offset:
0 int width; in pixels
4 int spacing; in 1/1000:th of a pixels
8 char data[]; Enough data to plot width * font->height pixels
Please note that if width is 0, there is no data.
Font formats:
id type
0 Raw 8bit data
1 RLE encoded data, char length, char data, 70% more compact than raw data
2 ZLib compressed data 60% more compact than RLE
Colortable types:
0 No colortable (the data is an alpha channel)
1 24bit RGB with alpha (index->color, 256*4 bytes, rgba)
2 8bit Greyscale with alpha (index->color, 256*2 bytes)
Kerningtable types:
0 No kerning table
1 numchars*numchars entries, each a signed char with the kerning value
2 numchar entries, each with a list of kerning pairs, like this:
int len
len * (short char, short value)
Image , Image.Image
Image.Font|int load(string filename)
Loads a font file to this font object.
Returns zero upon failure and a font object upon success.
The path to the font file.
write
void Image.Font(string filename)
Loads a font file to this font object. Similar to load() .
Image.Image write(string text, string ... more_text_lines)
Writes some text; thus creating an image object that can be used as mask or as a complete picture. One or more text lines may be provided.
text_extents , load , Image.Image->paste_mask , Image.Image->paste_alpha_color
int height()
Returns the font height.
baseline , text_extents
array(int) text_extents(string text, string ... more_text_lines)
Calculate extents of a text-image, that would be created by calling write with the same arguments. One or more lines of text may be provided.
|
write , height , baseline
void set_xspacing_scale(float scale)
void set_yspacing_scale(float scale)
Set spacing scale to write characters closer or more far away. This does not change scale of character, only the space between them.
int baseline()
Returns font baseline (pixels from top)
height , text_extents
void center()
Document this function.
void right()
Document this function.
void left()
Document this function.
| CLASS Image.Colortable |
This object keeps colortable information, mostly for image re-coloring (quantization).
The object has color reduction, quantisation, mapping and dithering capabilities.
Image , Image.Image , Image.Font , Image.GIF
void Image.Colortable()
void Image.Colortable(array(array(int)) colors)
void Image.Colortable(Image.Image image, int number)
void Image.Colortable(Image.Image image, int number, array(array(int)) needed)
void Image.Colortable(int r, int g, int b)
void Image.Colortable(int r, int g, int b, object array(int)
object add(array(array(int)) colors)
object add(Image.Image image, int number)
object add(Image.Image image, int number, array(array(int)) needed)
object add(int r, int g, int b)
object add(int r, int g, int b, object array(int)
create initiates a colortable object. Default is that no colors are in the colortable.
add takes the same argument(s) as create , thus adding colors to the colortable.
The colortable is mostly a list of colors, or more advanced, colors and weight.
The colortable could also be a colorcube, with or without additional scales. A colorcube is the by-far fastest way to find colors.
Example:
ct=colortable(my_image,256); // the best 256 colors
ct=colortable(my_image,256,({0,0,0})); // black and the best other 255
ct=colortable(({({0,0,0}),({255,255,255})})); // black and white
ct=colortable(6,7,6); // a colortable of 252 colors
ct=colortable(7,7,5, ({0,0,0}),({255,255,255}),11);
// a colorcube of 245 colors, and a greyscale of the rest -> 256
list of colors
source image
number of colors to get from the image
0 (zero) gives all colors in the image.
Default value is 256.
needed colors (to optimize selection of others to these given)
this will add to the total number of colors (see argument 'number')
size of sides in the colorcube, must (of course) be equal or larger than 2 - if smaller, the cube is ignored (no colors). This could be used to have only scales (like a greyscale) in the output.
This is to add the possibility of adding a scale of colors to the colorcube; for instance a grayscale using the arguments ({0,0,0}),({255,255,255}),17, adding a scale from black to white in 17 or more steps.
Colors already in the cube is used again to add the number of steps, if possible.
The total number of colors in the table is therefore r*b*g+step1+...+stepn.
max hash size is (probably, set by a #define) 32768 entries, giving maybe half that number of colors as maximum.
object cast(string to)
cast the colortable to an array or mapping, the array consists of Image.Color objects and are not in index order. The mapping consists of index:Image.Color pairs, where index is the index (int) of that color.
example: (mapping)Image.Colortable(img)
must be "string", "array" or "mapping".
array(object) corners()
Gives the eight corners in rgb colorspace as an array. The "black" and "white" corners are the first two.
object cubicles()
object cubicles(int r, int g, int b)
object cubicles(int r, int g, int b, int accuracy)
Set the colortable to use the cubicles algorithm to lookup the closest color. This is a mostly very fast and very accurate way to find the correct color, and the default algorithm.
The colorspace is divided in small cubes, each cube containing the colors in that cube. Each cube then gets a list of the colors in the cube, and the closest from the corners and midpoints between corners.
When a color is needed, the algorithm first finds the correct cube and then compares with all the colors in the list for that cube.
example: colors=Image.Colortable(img)->cubicles();
algorithm time: between O[m] and O[m * n], where n is numbers of colors and m is number of pixels
The arguments can be heavy trimmed for the usage of your colortable; a large number (10×10×10 or bigger) of cubicles is recommended when you use the colortable repeatedly, since the calculation takes much more time than usage.
recommended values:
image size setup
100×100 cubicles(4,5,4) (default)
1000×1000 cubicles(12,12,12) (factor 2 faster than default)
In some cases, the full method is faster.
![]() |
![]() |
![]() |
| original | default cubicles, 16 colors |
accuracy=200 |
Size, ie how much the colorspace is divided. Note that the size of each cubicle is at least about 8b, and that it takes time to calculate them. The number of cubicles are r*g*b, and default is 4,5,4, ie 80 cubicles. This works good for 200±100 colors.
Accuracy when checking sides of cubicles. Default is 16. A value of 1 gives complete accuracy, ie cubicle() method gives exactly the same result as full(), but takes (in worst case) 16× the time to calculate.
the object being called
this method doesn't figure out the cubicles, this is done on the first use of the colortable.
Not applicable to colorcube types of colortable.
object floyd_steinberg()
object floyd_steinberg(int bidir, int|float forward, int|float downforward, int|float down, int|float downback, int|float factor)
Set dithering method to floyd_steinberg.
The arguments to this method is for fine-tuning of the algorithm (for computer graphics wizards).
![]() |
![]() |
![]() |
| original | floyd_steinberg to a 4×4×4 colorcube | floyd_steinberg to 16 chosen colors |
Set algorithm direction of forward. -1 is backward, 1 is forward, 0 for toggle of direction each line (default).
Set error correction directions. Default is forward=7, downforward=1, down=5, downback=3.
Error keeping factor. Error will increase if more than 1.0 and decrease if less than 1.0. A value of 0.0 will cancel any dither effects. Default is 0.95.
the object being called
object full()
Set the colortable to use full scan to lookup the closest color.
example: colors=Image.Colortable(img)->full();
algorithm time: O[n*m], where n is numbers of colors and m is number of pixels
the object being called
Not applicable to colorcube types of colortable.
cubicles , map
int(0..1) greyp()
Returns true if this colortable only contains greyscale.
object image()
cast the colortable to an image object
each pixel in the image object is an entry in the colortable
the resulting image object
object map(object image)
object `*(object image)
object ``*(object image)
object map(string data, int xsize, int ysize)
object `*(string data, int xsize, int ysize)
object ``*(string data, int xsize, int ysize)
Map colors in an image object to the colors in the colortable, and creates a new image with the closest colors.
![]() |
![]() |
![]() |
![]() |
![]() |
no dither | |
![]() |
![]() |
![]() |
![]() |
![]() |
floyd_steinberg dither | |
![]() |
![]() |
![]() |
![]() |
![]() |
ordered dither | |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
randomcube dither |
| original | 2 | 4 | 8 | 16 | 32 colors |
a new image object
Flat (not cube) colortable and not 'full ' method: this method does figure out the data needed for the lookup method, which may take time the first use of the colortable - the second use is quicker.
cubicles , full
object nodither()
Set no dithering (default).
the object being called
object ordered()
object ordered(int r, int g, int b)
object ordered(int r, int g, int b, int xsize, int ysize)
object ordered(int r, int g, int b, int xsize, int ysize, int x, int y)
object ordered(int r, int g, int b, int xsize, int ysize, int rx, int ry, int gx, int gy, int bx, int by)
Set ordered dithering, which gives a position-dependent error added to the pixel values.
![]() |
![]() |
![]() |
![]() |
| original | mapped to Image.Colortable(6,6,6)-> |
||
| ordered (42,42,42,2,2) |
ordered() | ordered (42,42,42, 8,8, 0,0, 0,1, 1,0) |
|
![]() |
![]() |
![]() |
![]() |
The maximum error. Default is 32, or colorcube steps (256/size).
Size of error matrix. Default is 8×8. Only values which factors to multiples of 2 and 3 are possible to choose (2,3,4,6,8,12,...).
Offset for the error matrix. x and y is for both red, green and blue values, the other is individual.
the object being called
randomcube , nodither , floyd_steinberg , create
object randomcube()
object randomcube(int r, int g, int b)
object randomgrey()
object randomgrey(int err)
Set random cube dithering. Color choosen is the closest one to color in picture plus (flat) random error; color±random(error).
The randomgrey method uses the same random error on red, green and blue and the randomcube method has three random errors.
![]() |
![]() |
![]() |
| original | mapped to Image.Colortable(4,4,4)-> |
|
| randomcube() | randomgrey() | |
![]() |
![]() |
![]() |
The maximum error. Default is 32, or colorcube step.
the object being called
randomgrey method needs colorcube size to be the same on red, green and blue sides to work properly. It uses the red colorcube value as default.
ordered , nodither , floyd_steinberg , create
object reduce(int colors)
object reduce_fs(int colors)
reduces the number of colors
All needed (see create ) colors are kept.
reduce_fs creates and keeps the outmost corners of the color space, to improve floyd-steinberg dithering result. (It doesn't work very well, though.)
target number of colors
the new Colortable object
this algorithm assumes all colors are different to begin with (!)
reduce_fs keeps the "corners" as "needed colors".
corners
object rigid()
object rigid(int r, int g, int b)
Set the colortable to use the "rigid" method of looking up colors.
This is a very simple way of finding the correct color. The algorithm initializes a cube with r x g x b colors, where every color is chosen by closest match to the corresponding coordinate.
This format is not recommended for exact match, but may be usable when it comes to quickly view pictures on-screen.
It has a high init-cost and low use-cost. The structure is initiated at first usage.
the object being called
Not applicable to colorcube types of colortable.
cubicles , map , full
object spacefactors(int r, int g, int b)
Colortable tuning option, this sets the color space distance factors. This is used when comparing distances in the colorspace and comparing grey levels.
Default factors are 3, 4 and 1; blue is much darker than green. Compare with Image.Image->grey ().
the object being called
This has no sanity check. Some functions may bug if the factors are to high - color reduction functions sums grey levels in the image, this could exceed maxint in the case of high factors. Negative values may also cause strange effects. *grin*
object `+(object with, object mixed...more)
sums colortables
Colortable object with colors to add
the resulting new Colortable object
object `-(object with, object mixed...more)
subtracts colortables
Colortable object with colors to subtract
the resulting new Colortable object
| CLASS Image.Layer |
layers
object set_image(Image.Image image)
object set_image(Image.Image image, Image.Image alpha_channel)
object|int(0..) image()
object|int(0..) alpha()
Set/change/get image and alpha channel for the layer. You could also cancel the channels giving 0 instead of an image object.
image and alpha channel must be of the same size, or canceled.
object set_alpha_value(float value)
float alpha_value()
Set/get the general alpha value of this layer. This is a float value between 0 and 1, and is multiplied with the alpha channel.
object autocrop()
object autocrop(int(0..1) left, int(0..1) right, int(0..1) top, int(0..1) bottom)
array(int) find_autocrop()
array(int) find_autocrop(int(0..1) left, int(0..1) right, int(0..1) top, int(0..1) bottom)
This crops (of finds) a suitable crop, non-destructive crop. The layer alpha channel is checked, and edges that is transparent is removed.
(What really happens is that the image and alpha channel is checked, and edges equal the fill setup is cropped away.)
find_autocrop () returns an array of xoff,yoff,xsize,ysize, which can be fed to crop ().
A tiled image will not be cropped at all.
left...bottom arguments can be used to tell what sides cropping are ok on.
crop , Image.Image->autocrop
object set_mode(string mode)
string mode()
array(string) available_modes()
Set/get layer mode. Mode is one of these:
| top layer | |
![]() | |
| bottom layer | |
![]() | |
| normal | |
![]() | D=L applied with alpha: D=(L*aL+S*(1-aL)*aS) / (aL+(1-aL)*aS), aD=(aL+(1-aL)*aS) |
| add | |
![]() | D=L+S applied with alpha, aD=aS |
| subtract | |
![]() | D=S-L applied with alpha, aD=aS |
| multiply | |
![]() | D=S*L applied with alpha, aD=aS |
| divide | |
![]() | D=S/L applied with alpha, aD=aS |
| negdivide | |
![]() | D=1.0-S/L applied with alpha, aD=aS |
| modulo | |
![]() | D=S%L applied with alpha, aD=aS |
| invsubtract | |
![]() | D=L-S applied with alpha, aD=aS |
| invdivide | |
![]() | D=L/S applied with alpha, aD=aS |
| invmodulo | |
![]() | D=L%S applied with alpha, aD=aS |
| imultiply | |
![]() | D=(1-L)*S applied with alpha, aD=aS |
| idivide | |
![]() | D=S/(1-L) applied with alpha, aD=aS |
| invidivide | |
![]() | D=L/(1-S) applied with alpha, aD=aS |
| difference | |
![]() | D=abs(L-S) applied with alpha, aD=aS |
| max | |
![]() | D=max(L,S) applied with alpha, aD=aS |
| min | |
![]() | D=min(L,S) applied with alpha, aD=aS |
| bitwise_and | |
![]() | D=L&S applied with alpha, aD=aS |
| bitwise_or | |
![]() | D=L|S applied with alpha, aD=aS |
| bitwise_xor | |
![]() | D=L^S applied with alpha, aD=aS |
| replace | |
![]() | D=(L*aL+S*(1-aL)*aS) / (aL+(1-aL)*aS), aD=aS |
| red | |
![]() | Dr=(Lr*aLr+Sr*(1-aLr)*aSr) / (aLr+(1-aLr)*aSr), Dgb=Sgb, aD=aS |
| green | |
![]() | Dg=(Lg*aLg+Sg*(1-aLg)*aSg) / (aLg+(1-aLg)*aSg), Drb=Srb, aD=aS |
| blue | |
![]() | Db=(Lb*aLb+Sb*(1-aLb)*aSb) / (aLb+(1-aLb)*aSb), Drg=Srg, aD=aS |
| hardlight | |
![]() | Like photoshop hardlight layer mode, aD=aS |
| replace_hsv | |
![]() | Dhsv=Lhsv apply with alpha, aD=aS |
| hue | |
![]() | Dh=Lh apply with alpha, Dsv=Lsv, aD=aS |
| saturation | |
![]() | Ds=Ls apply with alpha, Dhv=Lhv, aD=aS |
| value | |
![]() | Dv=Lv apply with alpha, Dhs=Lhs, aD=aS |
| color | |
![]() | Dhs=Lhs apply with alpha, Dv=Lv, aD=aS |
| value_mul | |
![]() | Dv=Lv*Sv apply with alpha, Dhs=Lhs, aD=aS |
| darken | |
![]() | Dv=min(Lv,Sv) apply with alpha, Dhs=Lhs, aD=aS |
| lighten | |
![]() | Dv=max(Lv,Sv) apply with alpha, Dhs=Lhs, aD=aS |
| saturate | |
![]() | Ds=max(Ls,Ss) apply with alpha, Dhv=Lhv, aD=aS |
| desaturate | |
![]() | Ds=min(Ls,Ss) apply with alpha, Dhv=Lhv, aD=aS |
| hls_replace | |
![]() | Dhls=Lhls apply with alpha, aD=aS |
| hls_hue | |
![]() | Dh=Lh apply with alpha, Dsv=Lsv, aD=aS |
| hls_saturation | |
![]() | Ds=Ls apply with alpha, Dhv=Lhv, aD=aS |
| hls_lightness | |
![]() | Dl=Ll apply with alpha, Dhs=Lhs, aD=aS |
| hls_color | |
![]() | Dhs=Lhs apply with alpha, Dl=Ll, aD=aS |
| hls_lightness_mul | |
![]() | Dl=Ll*Sl apply with alpha, Dhs=Lhs, aD=aS |
| hls_darken | |
![]() | Dl=min(Ll,Sl) apply with alpha, Dhs=Lhs, aD=aS |
| hls_lighten | |
![]() | Dl=max(Ll,Sl) apply with alpha, Dhs=Lhs, aD=aS |
| hls_saturate | |
![]() | Ds=max(Ls,Ss) apply with alpha, Dhl=Lhl, aD=aS |
| hls_desaturate | |
![]() | Ds=min(Ls,Ss) apply with alpha, Dhl=Lhl, aD=aS |
| dissolve | |
![]() | i=random 0 or 1, D=i?L:S, aD=i+aS |
| behind | |
![]() | D=(S*aS+L*(1-aS)*aL) / (aS+(1-aS)*aL), aD=(aS+(1-aS)*aL); simply swap S and L |
| erase | |
![]() | D=S, aD=aS*(1-aL) |
| screen | |
![]() | 1-(1-S)*(1-L) applied with alpha, aD=aS |
| overlay | |
![]() | (1-(1-a)*(1-b)-a*b)*a+a*b applied with alpha, aD=aS |
| burn_alpha | |
![]() | aD=aL+aS applied with alpha, D=L+S; experimental, may change or be removed |
| equal | |
![]() | each channel D=max if L==S, 0 otherwise, apply with alpha |
| not_equal | |
![]() | each channel D=max if L!=S, 0 otherwise, apply with alpha |
| less | |
![]() | each channel D=max if L<S, 0 otherwise, apply with alpha |
| more | |
![]() | each channel D=max if L>S, 0 otherwise, apply with alpha |
| less_or_equal | |
![]() | each channel D=max if L<=S, 0 otherwise, apply with alpha |
| more_or_equal | |
![]() | each channel D=max if L>=S, 0 otherwise, apply with alpha |
| logic_equal | |
![]() | logic: D=white and opaque if L==S, black and transparent otherwise |
| logic_not_equal | |
![]() | logic: D=white and opaque if any L!=S, black and transparent otherwise |
| logic_strict_less | |
![]() | logic: D=white and opaque if all L<S, black and transparent otherwise |
| logic_strict_more | |
![]() | logic: D=white and opaque if all L>S, black and transparent otherwise |
| logic_strict_less_equal | |
![]() | logic: D=white and opaque if all L<=L, black and transparent otherwise |
| logic_strict_more_equal | |
![]() | logic: D=white and opaque if all L>=L, black and transparent otherwise |
available_modes () simply gives an array containing the names of these modes.
image and alpha channel must be of the same size, or canceled.
mapping(string:mixed)|string cast()
([ "xsize":int, "ysize":int, "image":image, "alpha":image, "xoffset":int, "yoffset":int, "fill":image, "fill_alpha":image "tiled":int, "mode":string ])
object clone()
Creates a copy of the called object.
the copy
void Image.Layer(object image, object alpha, string mode)
void Image.Layer(mapping info)
void Image.Layer()
void Image.Layer(int xsize, int ysize, object color)
void Image.Layer(object color)
The Layer construct either three arguments,
the image object, alpha channel and mode, or
a mapping with optional elements:
"image":image,
// default: black
"alpha":alpha,
// alpha channel object
// default: full opaque
"mode":string mode,
// layer mode, see mode .
// default: "normal"
"alpha_value":float(0.0-1.0),
// layer general alpha value
// default is 1.0; this is multiplied
// with the alpha channel.
"xoffset":int,
"yoffset":int,
// offset of this layer
"fill":Color,
"fill_alpha":Color,
// fill color, ie what color is used
// "outside" the image. default: black
// and black (full transparency).
"tiled":int(0|1),
// select tiling; if 1, the image
// will be tiled. deafult: 0, off
The layer can also be created "empty",
either giving a size and color -
this will give a filled opaque square,
or a color, which will set the "fill"
values and fill the whole layer with an
opaque color.
All values can be modified after object creation.
image and alpha channel must be of the same size.
object crop(int xoff, int yoff, int xsize, int ysize)
Crops this layer at this offset and size. Offset is not relative the layer offset, so this can be used to crop a number of layers simuntaneously.
The fill values are used if the layer is enlarged.
a new layer object
The new layer object may have the same image object, if there was no cropping to be done.
array(string) description()
Layer descriptions
object set_fill(Color color)
object set_fill(Color color, Color alpha)
object fill()
object fill_alpha()
Set/query fill color and alpha, ie the color used "outside" the image. This is mostly useful if you want to "frame" a layer.
mixed set_misc_value(object mixedwhat, object mixedto)
mixed get_misc_value(object mixedwhat)
Set or query misc. attributes for the layer.
As an example, the XCF and PSD image decoders set the 'name' attribute to the name the layer had in the source file.
object set_offset(int x, int y)
int xoffset()
int yoffset()
Set/query layer offset.
object set_tiled(int yes)
int tiled()
Set/query tiled flag. If set, the image and alpha channel will be tiled rather then framed by the fill values.
int xsize()
int ysize()
Query layer offset. This is the same as layer image/alpha image size.
| CLASS Image.Image |
The main object of the Image module, this object is used as drawing area, mask or result of operations.
basic:
clear ,
clone ,
create ,
xsize ,
ysize
plain drawing:
box ,
circle ,
getpixel ,
line ,
setcolor ,
setpixel ,
threshold ,
polyfill
operators:
`& ,
`* ,
`+ ,
`- ,
`== ,
`> ,
`< ,
`|
pasting images:
paste ,
paste_alpha ,
paste_alpha_color ,
paste_mask
getting subimages, scaling, rotating:
autocrop ,
clone ,
copy ,
dct ,
mirrorx ,
rotate ,
rotate_ccw ,
rotate_cw ,
rotate_expand ,
scale ,
skewx ,
skewx_expand ,
skewy ,
skewy_expand
calculation by pixels:
apply_matrix ,
change_color ,
color ,
distancesq ,
grey ,
invert ,
modify_by_intensity ,
outline
select_from ,
rgb_to_hsv ,
hsv_to_rgb ,
rgb_to_yuv ,
yuv_to_rgb ,
average , max , min , sum , sumf , find_min , find_max
special pattern drawing:
noise ,
turbulence ,
test ,
tuned_box ,
gradients ,
random
Image , Image.Font , Image.Colortable , Image.X
object mirrorx()
mirrors an image:
![]() |
![]() |
| original | ->mirrorx(); |
the new image object
object mirrory()
mirrors an image:
![]() |
![]() |
| original | ->mirrory(); |
object rotate(int|float angle)
object rotate(int|float angle, int r, int g, int b)
object rotate_expand(int|float angle)
object rotate_expand(int|float angle, int r, int g, int b)
Rotates an image a certain amount of degrees (360° is a complete rotation) counter-clockwise:
![]() |
![]() |
![]() |
| original | ->rotate(15,255,0,0); | ->rotate_expand(15); |
The "expand" variant of functions stretches the image border pixels rather then filling with the given or current color.
This rotate uses the skewx () and skewy () functions.
the number of degrees to rotate
color to fill with; default is current
the new image object
object rotate_ccw()
rotates an image counter-clockwise, 90 degrees.
![]() |
![]() |
| original | ->rotate_ccw(); |
the new image object
object rotate_cw()
rotates an image clockwise, 90 degrees.
![]() |
![]() |
| original | ->rotate_cw(); |
the new image object
object scale(float factor)
object scale(0.5)
object scale(float xfactor, float yfactor)
scales the image with a factor, 0.5 is an optimized case.
factor to use for both x and y
separate factors for x and y
the new image object
object scale(int newxsize, int newysize)
object scale(0, int newysize)
object scale(int newxsize, 0)
scales the image to a specified new size, if one of newxsize or newysize is 0, the image aspect ratio is preserved.
new image size in pixels
the new image object
resulting image will be 1x1 pixels, at least
object skewx(int x)
object skewx(float yfactor)
object skewx(int x, int r, int g, int b)
object skewx(float yfactor, int r, int g, int b)
object skewx_expand(int x)
object skewx_expand(float yfactor)
object skewx_expand(int x, int r, int g, int b)
object skewx_expand(float yfactor, int r, int g, int b)
Skews an image an amount of pixels or a factor; a skew-x is a transformation:
![]() |
![]() |
![]() |
| original | ->skewx(15,255,0,0); | ->skewx_expand(15); |
the number of pixels The "expand" variant of functions stretches the image border pixels rather then filling with the given or current color.
best described as: x=yfactor*this->ysize()
color to fill with; default is current
the new image object
object skewy(int y)
object skewy(float xfactor)
object skewy(int y, int r, int g, int b)
object skewy(float xfactor, int r, int g, int b)
object skewy_expand(int y)
object skewy_expand(float xfactor)
object skewy_expand(int y, int r, int g, int b)
object skewy_expand(float xfactor, int r, int g, int b)
Skews an image an amount of pixels or a factor; a skew-y is a transformation:
![]() |
![]() |
![]() |
| original | ->skewy(15,255,0,0); | ->skewy_expand(15); |
The "expand" variant of functions stretches the image border pixels rather then filling with the given or current color.
the number of pixels
best described as: t=xfactor*this->xsize()
color to fill with; default is current
the new image object
void noise(array(float|int|array(int)) colorrange)
void noise(array(float|int|array(int)) colorrange, float scale, float xdiff, float ydiff, float cscale)
Gives a new image with the old image's size, filled width a 'noise' pattern.
The random seed may be different with each instance of pike.
Example:
->noise( ({0,({255,0,0}), 0.3,({0,255,0}), 0.6,({0,0,255}), 0.8,({255,255,0})}), 0.2,0.0,0.0,1.0 );
colorrange table
default value is 0.1
default value is 0,0
default value is 1
turbulence
object random()
object random(int seed)
object randomgrey()
object random(greyint seed)
Gives a randomized image;
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
| original | ->random() | ->random(17) | greyed (same again) |
color(red) (same again) |
...red channel |
Use with ->grey () or ->color () for one-color-results.
a new image
test , noise
void turbulence(array(float|int|array(int)) colorrange)
void turbulence(array(float|int|array(int)) colorrange, int octaves, float scale, float xdiff, float ydiff, float cscale)
gives a new image with the old image's size, filled width a 'turbulence' pattern
The random seed may be different with each instance of pike.
Example:
->turbulence( ({0,({229,204,204}), 0.9,({229,20,20}), 0.9,Color.black}) );

colorrange table
default value is 3
default value is 0.1
default value is 0,0
default value is 1
noise , Image.Color
object apply_curve(object array(int(0..255)
object apply_curve(object array(int(0..255)
object apply_curve(object stringchannel, object array(int(0..255)
Apply a lookup-table on all pixels in an image. If only one curve is passed, use the same curve for red, green and blue. If 'channel' is specified, the curve is only applied to the specified channel.
An array with 256 elements, each between 0 and 255. It is used as a look-up table, if the pixel value is 2 and curve[2] is 10, the new pixel value will be 10.
one of "red", "green", "blue", "value", "saturation" and "hue".
a new image object
gamma , `* , modify_by_intensity
object apply_matrix(array(array(int|array(int))) matrix)
object apply_matrix(array(array(int|array(int))) matrix, int r, int g, int b)
object apply_matrix(array(array(int|array(int))) matrix, int r, int g, int b, int|float div)
Applies a pixel-transform matrix, or filter, to the image.
2 2
pixel(x,y)= base+ k ( sum sum pixel(x+k-1,y+l-1)*matrix(k,l) )
k=0 l=0
1/k is sum of matrix, or sum of matrix multiplied with div. base is given by r,g,b and is normally black.
blur (ie a 2d gauss function):
({({1,2,1}),
({2,5,2}),
({1,2,1})})
|
|
|
| original | ||
sharpen (k>8, preferably 12 or 16):
({({-1,-1,-1}),
({-1, k,-1}),
({-1,-1,-1})})
|
| |
edge detect:
({({1, 1,1}),
({1,-8,1}),
({1, 1,1})})
|
| |
horisontal edge detect (get the idea):
({({0, 0,0}),
({1,-2,1}),
({0, 0,0})})
|
| |
emboss (might prefer to begin with a grey image):
({({2, 1, 0}),
({1, 0,-1}),
({0,-1,-2})}), 128,128,128, 3
|
|
|
| greyed |
This function is not very fast.
the matrix; innermost is a value or an array with red, green, blue values for red, green, blue separation.
base level of result, default is zero
division factor, default is 1.0.
the new image object
object autocrop()
object autocrop(int border)
object autocrop(int border, Color color)
object autocrop(int border, int left, int right, int top, int bottom)
object autocrop(int border, int left, int right, int top, int bottom, Color color)
array(int) find_autocrop()
array(int) find_autocrop(int border)
array(int) find_autocrop(int border, int left, int right, int top, int bottom)
Removes "unneccesary" borders around the image, adds one of its own if wanted to, in selected directions.
"Unneccesary" is all pixels that are equal -- ie if all the same pixels to the left are the same color, that column of pixels are removed.
The find_autocrop() function simply returns x1,y1,x2,y2 for the kept area. (This can be used with copy later.)
which borders to scan and cut the image;
a typical example is removing the top and bottom unneccesary
pixels:
img=img->autocrop(0, 0,0,1,1);
the new image object
copy
object bitscale(float factor)
object bitscale(float xfactor, float yfactor)
scales the image with a factor, without smoothing. This routine is faster than scale, but gives less correct results
![]() |
![]() |
![]() |
| original | bitscale(0.75) | scale(0.75) |
factor to use for both x and y
separate factors for x and y
the new image object
object bitscale(int newxsize, int newysize)
object bitscale(0, int newysize)
object bitscale(int newxsize, 0)
scales the image to a specified new size, if one of newxsize or newysize is 0, the image aspect ratio is preserved.
new image size in pixels
the new image object
resulting image will be 1x1 pixels, at least
string blur(int no_pass)
A special case of apply_matrix that creates a blur effect. About four times faster than the generic apply_matrix. @[no_pass] is the number of times the blur matrix is applied.
![]() |
![]() |
![]() |
| original | blur(1) | blur(5) |
apply_matrix , grey_blur
object box(int x1, int y1, int x2, int y2)
object box(int x1, int y1, int x2, int y2, int r, int g, int b)
object box(int x1, int y1, int x2, int y2, int r, int g, int b, int alpha)
Draws a filled rectangle on the image.
![]() |
![]() |
![]() |
| original | ->box (40,10, 10,80, 0,255,0) |
->box (40,10, 10,80, 255,0,0,75) |
box corners
color of the box
alpha value
the object called
string cast(string type)
Cast the image to another datatype. Currently supported are string ("rgbrgbrgb...") and array (double array of Image.Color objects).
Image.Color , Image.X
object change_color(int tor, int tog, int tob)
object change_color(int fromr, int fromg, int fromb, int tor, int tog, int tob)
Changes one color (exact match) to another. If non-exact-match is preferred, check distancesq and paste_alpha_color .
destination color and next current color
source color, default is current color
a new (the destination) image object
object circle(int x, int y, int rx, int ry)
object circle(int x, int y, int rx, int ry, int r, int g, int b)
object circle(int x, int y, int rx, int ry, int r, int g, int b, int alpha)
Draws a circle on the image. The circle is not antialiased.
![]() |
![]() |
| original | ->circle (50,50, 30,50, 0,255,255) |
circle center
circle radius in pixels
color
alpha value
the object called
void clear()
void clear(int r, int g, int b)
void clear(int r, int g, int b, int alpha)
gives a new, cleared image with the same size of drawing area
![]() |
![]() |
| original | ->clear (0,128,255) |
color of the new image
new default alpha channel value
copy , clone
object clone()
object clone(int xsize, int ysize)
object clone(int xsize, int ysize, int r, int g, int b)
object clone(int xsize, int ysize, int r, int g, int b, int alpha)
Copies to or initialize a new image object.
![]() |
![]() |
![]() |
| original | clone | clone(50,50) |
size of (new) image in pixels, called image is cropped to that size
current color of the new image, default is black. Will also be the background color if the cloned image is empty (no drawing area made).
new default alpha channel value
the new object
copy , create
object color()
object color(int value)
object color(int r, int g, int b)
Colorize an image.
The red, green and blue values of the pixels are multiplied with the given value(s). This works best on a grey image...
The result is divided by 255, giving correct pixel values.
If no arguments are given, the current color is used as factors.
![]() |
![]() |
| original | ->color(128,128,255); |
red, green, blue factors
factor
the new image object
grey , `* , modify_by_intensity
object copy()
object copy(int x1, int y1, int x2, int y2)
object copy(int x1, int y1, int x2, int y2, int r, int g, int b)
object copy(int x1, int y1, int x2, int y2, int r, int g, int b, int alpha)
Copies this part of the image. The requested area can be smaller, giving a cropped image, or bigger - the new area will be filled with the given or current color.
![]() |
![]() |
![]() |
| original | ->copy (5,5, XSIZE-6,YSIZE-6) |
->copy (-5,-5, XSIZE+4,YSIZE+4, 10,75,10) |
The requested new area. Default is the old image size.
color of the new image
new default alpha channel value
a new image object
clone (void) and copy (void) does the same operation
clone , autocrop
void Image.Image()
void Image.Image(int xsize, int ysize)
void Image.Image(int xsize, int ysize, Color color)
void Image.Image(int xsize, int ysize, int r, int g, int b)
void Image.Image(int xsize, int ysize, int r, int g, int b, int alpha)
void Image.Image(int xsize, int ysize, string method, method ...)
Initializes a new image object.
![]() |
![]() |
| Image.Image (XSIZE,YSIZE) |
Image.Image (XSIZE,YSIZE,255,128,0) |
The image can also be calculated from some special methods, for convinience:
channel modes; followed by a number of 1-char-per-pixel strings
or image objects (where red channel will be used),
or an integer value:
"grey" : make a grey image (needs 1 source: grey)
"rgb" : make an rgb image (needs 3 sources: red, green and blue)
"cmyk" : make a rgb image from cmyk (cyan, magenta, yellow, black)
"adjusted_cmyk" : make a rgb image from cmyk
(cyan, magenta, yellow, black) where the colors aren't
100% pure (C: 009ee0, M: e2007a, Y: ffec00, K: 1a171b).
generate modes; all extra arguments is given to the
generation function. These has the same name as the method:
"test ,"
"gradients "
"noise "
"turbulence "
"random "
"randomgrey "
specials cases:
"tuned_box " (coordinates is automatic)
size of (new) image in pixels
background color (will also be current color), default color is black
default alpha channel value
SIGSEGVS can be caused if the size is too big, due to unchecked overflow - (xsize*ysize)&MAXINT is small enough to allocate.
copy , clone , Image.Image
object distancesq()
object distancesq(int r, int g, int b)
Makes an grey-scale image, for alpha-channel use.
The given value (or current color) are used for coordinates in the color cube. Each resulting pixel is the distance from this point to the source pixel color, in the color cube, squared, rightshifted 8 steps:
p = pixel color
o = given color
d = destination pixel
d.red=d.blue=d.green=
((o.red-p.red)²+(o.green-p.green)²+(o.blue-p.blue)²)>>8
![]() |
![]() |
![]() |
![]() |
| original | distance² to cyan | ...to purple | ...to yellow |
red, green, blue coordinates
the new image object
select_from
object gamma(float g)
object gamma(float gred, object floatggreen, object floatgblue)
Calculate pixels in image by gamma curve.
Intensity of new pixels are calculated by:
i' = i^g
For example, you are viewing your image on a screen with gamma 2.2. To correct your image to the correct gamma value, do something like:
my_display_image(my_image()->gamma(1/2.2);
gamma value
a new image object
grey , `* , color
array(int) getpixel(int x, int y)
position of the pixel
color of the requested pixel -- ({int red,int green,int blue})
int gradients(array(int) point, object ...)
int gradients(array(int) point, object ..., object floatgrad)
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
| original | 2 color gradient |
10 color gradient |
3 colors, grad=4.0 |
3 colors, grad=1.0 |
3 colors, grad=0.25 |
the new image
object grey()
object grey(int r, int g, int b)
Makes a grey-scale image (with weighted values).
![]() |
![]() |
![]() |
| original | ->grey(); | ->grey(0,0,255); |
weight of color, default is r=87,g=127,b=41, which should be pretty accurate of what the eyes see...
the new image object
color , `* , modify_by_intensity
object grey_blur(int no_pass)
Works like blur, but only operates on the r color channel. A faster alternative to blur for grey scale images. @[no_pass] is the number of times the blur matrix is applied.
![]() |
![]() |
![]() |
| original | grey_blur(1) | grey_blur(5) |
blur
object rgb_to_hsv()
object hsv_to_rgb()
Converts RGB data to HSV data, or the other way around. When converting to HSV, the resulting data is stored like this: pixel.r = h; pixel.g = s; pixel.b = v;
When converting to RGB, the input data is asumed to be placed in the pixels as above.
![]() |
![]() |
![]() |
| original | ->hsv_to_rgb(); | ->rgb_to_hsv(); |
![]() |
![]() |
![]() |
| tuned box (below) | the rainbow (below) | same, but rgb_to_hsv() |
HSV to RGB calculation:
in = input pixel
out = destination pixel
h=-pos*c_angle*3.1415/(float)NUM_SQUARES;
out.r=(in.b+in.g*cos(in.r));
out.g=(in.b+in.g*cos(in.r + pi*2/3));
out.b=(in.b+in.g*cos(in.r + pi*4/3));
RGB to HSV calculation: Hmm.
Example: Nice rainbow.
object i = Image.Image(200,200);
i = i->tuned_box(0,0, 200,200,
({ ({ 255,255,128 }), ({ 0,255,128 }),
({ 255,255,255 }), ({ 0,255,255 })}))
->hsv_to_rgb();
the new image object
object invert()
Invert an image. Each pixel value gets to be 255-x, where x is the old value.
![]() |
![]() |
![]() |
| original | ->invert(); | ->rgb_to_hsv()->invert()->hsv_to_rgb(); |
the new image object
object line(int x1, int y1, int x2, int y2)
object line(int x1, int y1, int x2, int y2, int r, int g, int b)
object line(int x1, int y1, int x2, int y2, int r, int g, int b, int alpha)
Draws a line on the image. The line is not antialiased.
![]() |
![]() |
| original | ->line (50,10, 10,50, 255,0,0) |
line endpoints
color
alpha value
the object called
object modify_by_intensity(int r, int g, int b, int|array(int) ... vn)
Recolor an image from intensity values.
For each color an intensity is calculated, from r, g and b factors (see grey ), this gives a value between 0 and max.
The color is then calculated from the values given, v1 representing the intensity value of 0, vn representing max, and colors between representing intensity values between, linear.
![]() |
![]() |
| original | ->grey()->modify_by_intensity(1,0,0, 0,({255,0,0}),({0,255,0})); |
red, green, blue intensity factors
destination color
the new image object
grey , `* , color
object outline()
object outline(int olr, int olg, int olb)
object outline(int olr, int olg, int olb, int bkgr, int bkgg, int bkgb)
object outline(array(array(int)) mask)
object outline(array(array(int)) mask, int olr, int olg, int olb)
object outline(array(array(int)) mask, int olr, int olg, int olb, int bkgr, int bkgg, int bkgb)
object outline_mask()
object outline_mask(int bkgr, int bkgg, int bkgb)
object outline_mask(array(array(int)) mask)
object outline_mask(array(array(int)) mask, int bkgr, int bkgg, int bkgb)
Makes an outline of this image, ie paints with the given color around the non-background pixels.
Default is to paint above, below, to the left and the right of these pixels.
You can also run your own outline mask.
The outline_mask function gives the calculated outline as an alpha channel image of white and black instead.
![]() |
![]() |
![]() |
| original | masked through threshold |
...and outlined with red |
mask matrix. Default is ({({0,1,0}),({1,1,1}),({0,1,0})}).
outline color. Default is current.
background color (what color to outline to); default is color of pixel 0,0.
division factor, default is 1.0.
the new image object
no antialias!
object write_lsb_rgb(string what)
object write_lsb_grey(string what)
string read_lsb_rgb()
string read_lsb_grey()
These functions read/write in the least significant bit of the image pixel values. The _rgb() functions read/write on each of the red, green and blue values, and the grey keeps the same lsb on all three.
The string is nullpadded or cut to fit.
the hidden message
the current object or the read string
object rgb_to_yuv()
object yuv_to_rgb()
Converts RGB data to YUV (YCrCb) data, or the other way around. When converting to YUV, the resulting data is stored like this: pixel.r = v (cr); pixel.g = y; pixel.b = u (cb);
When converting to RGB, the input data is asumed to be placed in the pixels as above.
![]() |
![]() |
![]() |
| original | ->yuv_to_rgb(); | ->rgb_to_yuv(); |
![]() |
![]() |
![]() |
| tuned box (below) | the rainbow (below) | same, but rgb_to_yuv() |
RGB to YUB calculation (this follows CCIR.601):
in = input pixel
out = destination pixel
Ey = 0.299*in.r+0.587*in.g+0.114*in.b
Ecr = 0.713*(in.r - Ey) = 0.500*in.r-0.419*in.g-0.081*in.b
Ecb = 0.564*(in.b - Ey) = -0.169*in.r-0.331*in.g+0.500*in.b
out.r=0.875*Ecr+128
out.g=0.86*Ey+16
out.b=0.875*Ecb+128
Example: Nice rainbow.
object i = Image.Image(200,200);
i = i->tuned_box(0,0, 200,200,
({ ({ 255,255,128 }), ({ 0,255,128 }),
({ 255,255,255 }), ({ 0,255,255 })}))
->yuv_to_rgb();
the new image object
object select_from(int x, int y)
object select_from(int x, int y, int edge_value)
Makes an grey-scale image, for alpha-channel use.
This is very close to a floodfill.
The image is scanned from the given pixel, filled with 255 if the color is the same, or 255 minus distance in the colorcube, squared, rightshifted 8 steps (see distancesq ).
When the edge distance is reached, the scan is stopped. Default edge value is 30. This value is squared and compared with the square of the distance above.
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
| 35, 35, 16 | 35, 35, 32 | 35, 35, 64 | 35, 35, 96 | 35, 35, 128 | 35, 35, 192 | 35, 35, 256 |
![]() |
![]() |
| original | original * select_from(35,35,200) |
originating pixel in the image
the new image object
distancesq
object setcolor(int r, int g, int b)
object setcolor(int r, int g, int b, int alpha)
set the current color
new color
new alpha value
the object called
object setpixel(int x, int y)
object setpixel(int x, int y, Image.Color c)
object setpixel(int x, int y, int r, int g, int b)
object setpixel(int x, int y, int r, int g, int b, int alpha)
| original | ->setpixel (10,10, 255,0,0) |
position of the pixel
color
alpha value
the object called
object test()
object test(int seed)
Generates a test image, currently random gradients.
![]() |
![]() |
![]() |
| original | ->test() | ...and again |
the new image
May be subject to change or cease without prior warning.
gradients , tuned_box
object threshold()
object threshold(int level)
object threshold(int r, int g, int b)
object threshold(Color color)
Makes a black-white image.
If any of red, green, blue parts of a pixel is larger then the given value, the pixel will become white, else black.
This method works fine with the grey method.
If no arguments are given, it will paint all non-black pixels white. (Ie, default is 0,0,0.)
![]() |
![]() |
![]() |
| original | ->threshold(100); | ->threshold(0,100,0); |
the new image object
The above statement "any ..." was changed from "all ..." in Pike 0.7 (9906). It also uses 0,0,0 as default input, instead of current color. This is more useful.
grey
object tuned_box(int x1, int y1, int x2, int y2, array(array(int)) corner_color)
Draws a filled rectangle with colors (and alpha values) tuned between the corners.
Tuning function is (1.0-x/xw)*(1.0-y/yw) where x and y is the distance to the corner and xw and yw are the sides of the rectangle.
![]() |
![]() |
![]() |
![]() |
| original | tuned box | solid tuning (blue,red,green,yellow) |
tuning transparency (as left + 255,128,128,0) |
rectangle corners
colors of the corners:
({x1y1,x2y1,x1y2,x2y2})
each of these is an array of integeres:
({r,g,b}) or ({r,g,b,alpha})
Default alpha channel value is 0 (opaque).
the object called
int xsize()
the width of the image
int ysize()
the height of the image
object paste(object image)
object paste(object image, int x, int y)
Pastes a given image over the current image.
image to paste (may be empty, needs to be an image object)
where to paste the image; default is 0,0
the object called
paste_mask , paste_alpha , paste_alpha_color
object paste_alpha(object image, int alpha)
object paste_alpha(object image, int alpha, int x, int y)
Pastes a given image over the current image, with the specified alpha channel value.
An alpha channel value of 0 leaves nothing of the original image in the paste area, 255 is meaningless and makes the given image invisible.
image to paste
alpha channel value
where to paste the image; default is 0,0
the object called
paste_mask , paste , paste_alpha_color
object paste_alpha_color(object mask)
object paste_alpha_color(object mask, int x, int y)
object paste_alpha_color(object mask, int r, int g, int b)
object paste_alpha_color(object mask, int r, int g, int b, int x, int y)
object paste_alpha_color(object mask, Color color)
object paste_alpha_color(object mask, Color color, int x, int y)
Pastes a given color over the current image, using the given mask as opaque channel.
A pixel value of 255 makes the result become the color given, 0 doesn't change anything.
The masks red, green and blue values are used separately. If no color are given, the current is used.
mask image
what color to paint with; default is current
where to paste the image; default is 0,0
the object called
paste_mask , paste_alpha , paste_alpha_color
object paste_mask(object image, object mask)
object paste_mask(object image, object mask, int x, int y)
Pastes a given image over the current image, using the given mask as opaque channel.
A pixel value of 255 makes the result become a pixel from the given image, 0 doesn't change anything.
The masks red, green and blue values are used separately.
image to paste
mask image
where to paste the image; default is 0,0
the object called
paste , paste_alpha , paste_alpha_color
object apply_max(array(array(int|array(int))) matrix)
object apply_max(array(array(int|array(int))) matrix, int r, int g, int b)
object apply_max(array(array(int|array(int))) matrix, int r, int g, int b, int|float div)
This is the same as apply_matrix, but it uses the maximum instead.
This function is not very fast.
the matrix; innermost is a value or an array with red, green, blue values for red, green, blue separation.
base level of result, default is zero
division factor, default is 1.0.
the new image object
experimental status; may not be exact the same output in later versions
string make_ascii(object orient1, object orient2, object orient3, object orient4, int|void tlevel, int|void xsize, int|void ysize)
This method creates a string that looks like
the image. Example:
//Stina is an image with a cat.
array(object) Stina4=Stina->orient4();
Stina4[1]*=215;
Stina4[3]*=215;
string foo=Stina->make_ascii(@Stina4,40,4,8);
some nice acsii-art.
experimental status; may not be exact the same
output in later versions
| / - \
hue= 0 64 128 192 (=red in an hsv image)
orient , orient4
object match(int|float scale, object objectneedle)
object match(int|float scale, object objectneedle, object objecthaystack_cert, object objectneedle_cert)
object match(int|float scale, object objectneedle, object objecthaystack_avoid, object intfoo)
object match(int|float scale, object objectneedle, object objecthaystack_cert, object objectneedle_cert, object objecthaystack_avoid, object intfoo)
This method creates an image that describes the match in every pixel in the image and the needle-Image.
new pixel value =
sum( my_abs(needle_pixel-haystack_pixel))
The new image only have the red rgb-part set.
Every pixel is divided with this value. Note that a proper value here depends on the size of the neadle.
The image to use for the matching.
This image should be the same size as the image itselves. A non-white-part of the haystack_cert-image modifies the output by lowering it.
The same, but for the needle-image.
This image should be the same size as the image itselves. If foo is less than the red value in haystack_avoid the corresponding matching-calculating is not calculated. The avoided parts are drawn in the color 0,100,0.
the new image object
experimental status; may not be exact the same output in later versions
phasev , phaseh
object phaseh()
object phasev()
object phasevh()
object phasehv()
Draws images describing the phase of the current image. phaseh gives the horizontal phase and phasev the vertical phase.
phaseh gives an image
where
max falling min rising
value= 0 64 128 192
0 is set if there is no way to determine if it is rising or falling. This is done for the every red, green and blue part of the image.
Phase images can be used to create ugly effects or to find meta-information in the orginal image.
![]() |
![]() |
![]() |
![]() |
![]() |
| original | phaseh() | phasev() | phasevh() | phasehv() |
the new image object
experimental status; may not be exact the same output in later versions
0 should not be set as explained above.
object dct(int newx, int newy)
Scales the image to a new size.
Method for scaling is rather complex; the image is transformed via a cosine transform, and then resampled back.
This gives a quality-conserving upscale, but the algorithm used is n*n+n*m, where n and m is pixels in the original and new image.
Recommended wrapping algorithm is to scale overlapping parts of the image-to-be-scaled.
This functionality is actually added as an true experiment, but works...
new image size in pixels
the new image object
Do NOT use this function if you don't know what you're dealing with! Read some signal theory first...
It doesn't use any fct (compare: fft) algorithms.
object orient(void|array(object) something)
array(object) orient4()
Draws images describing the orientation of the current image.
orient gives an HSV image
(run a hsv_to_rgb pass on it
to get a viewable image).
corresponding to the angle of the
orientation:
| / - \
hue= 0 64 128 192 (=red in an hsv image)
purple cyan green red
Red, green and blue channels are added
and not compared separately.
If you first use orient4 you can give its output as input to this function.
The orient4 function gives back 4 image objects, corresponding to the amount of different directions, see above.
an image or an array of the four new image objects
experimental status; may not be exact the same output in later versions
object polyfill(array(int|float) ... curve)
fills an area with the current color
curve(s), ({x1,y1,x2,y2,...,xn,yn}), automatically closed.
If any given curve is inside another, it will make a hole.
Image.Image(100,100)->setcolor(255,0,0,128)->
polyfill( ({ 20,20, 80,20, 80,80 }) );

the current object
Lines in the polygon may not be crossed without the crossing coordinate specified in both lines.
Inverted lines reported on Intel and Alpha processors.
setcolor
array(float) average()
array(int) min()
array(int) max()
array(int) sum()
array(float) sumf()
Gives back the average, minimum, maximum color value, and the sum of all pixel's color value.
sum() values can wrap! Most systems only have 31 bits available for positive integers. (Meaning, be careful with images that have more than 8425104 pixels.)
average() and sumf() may also wrap, but on a line basis. (Meaning, be careful with images that are wider than 8425104 pixels.) These functions may have a precision problem instead, during to limits in the 'double' C type and/or 'float' Pike type.
array(int) find_min()
array(int) find_max()
array(int) find_min(int r, int g, int b)
array(int) find_max(int r, int g, int b)
Gives back the position of the minimum or maximum pixel value, weighted to grey.
weight of color, default is r=87,g=127,b=41, same as the grey () method.
object `/(object operand)
object `/(Color color)
object `/(int value)
object `%(object operand)
object `%(Color color)
object `%(int value)
Divides pixel values and creates a new image from the result or the rest.
the other image to divide with; the images must have the same size.
if specified as color or value, it will act as a whole image of that color (or value).
the new image object
It isn't possible to do a modulo 256 either. (why?)
`- , `+ , `| , `& , `* , Image.Layer
object `&(object operand)
object `&(array(int) color)
object `&(int value)
makes a new image out of the minimum pixels values
the other image to compare with; the images must have the same size.
an array in format ({r,g,b}), this is equal to using an uniform-colored image.
equal to ({value,value,value}).
the new image object
`- , `+ , `| , `* , Image.Layer
int `==(object operand)
int `==(array(int) color)
int `==(int value)
int `<(object operand)
int `<(array(int) color)
int `<(int value)
int `>(object operand)
int `>(array(int) color)
int `>(int value)
Compares an image with another image or a color.
Comparision is strict and on pixel-by-pixel basis. (Means if not all pixel r,g,b values are correct compared with the corresponding pixel values, 0 is returned.)
the other image to compare with; the images must have the same size.
an array in format ({r,g,b}), this is equal to using an uniform-colored image.
equal to ({value,value,value}).
true (1) or false (0).
`< or `> on empty ("no image") image objects or images with different size will result in an error. `== is always true on two empty image objects and always false if one and only one of the image objects is empty or the images differs in size.
a>=b and a<=b between objects is equal to !(a<b) and !(a>b), which may not be what you want (since both < and > can return false, comparing the same images).
`- , `+ , `| , `* , `&
object `*(object operand)
object `*(array(int) color)
object `*(int value)
object `*(float value)
Multiplies pixel values and creates a new image. This can be useful to lower the values of an image, making it greyer, for instance:
image=image*128+64;
the other image to multiply with; the images must have the same size.
an array in format ({r,g,b}), this is equal to using an uniform-colored image.
equal to ({value,value,value}).
the new image object
`- , `+ , `| , `& , Image.Layer
object `+(object operand)
object `+(array(int) color)
object `+(int value)
adds two images; values are truncated at 255.
the image which to add.
an array in format ({r,g,b}), this is equal to using an uniform-colored image.
equal to ({value,value,value}).
the new image object
`- , `| , `& , `* , Image.Layer
object `-(object operand)
object `-(array(int) color)
object `-(int value)
makes a new image out of the difference
the other image to compare with; the images must have the same size.
an array in format ({r,g,b}), this is equal to using an uniform-colored image.
equal to ({value,value,value}).
the new image object
`+ , `| , `& , `* , Image.Layer , min , max , `==
object `|(object operand)
object `|(array(int) color)
object `|(int value)
makes a new image out of the maximum pixels values
the other image to compare with; the images must have the same size.
an array in format ({r,g,b}), this is equal to using an uniform-colored image.
equal to ({value,value,value}).
the new image object
`- , `+ , `& , `* , Image.Layer
| Module Image.SVG |
This is a glue against the librsvg-2.0 library, providing Scalable Vector Graphics (SVG) for Pike.
mapping decode_header(string data, void|mapping options)
Data is the SVG data, the charset must be unicode.
If options is specified, it contains one or more of the following options
|
The result is a mapping with the following members:
|
mapping _decode(string data, void|mapping options)
Data is the SVG data, the charset must be unicode.
If options is specified, it contains one or more of the following options
|
The result is a mapping with the following members:
|
array(Image.Layer) decode_layers(string data, void|mapping options)
Data is the SVG data, the charset must be unicode.
If options is specified, it contains one or more of the following options
|
The result is an array of Image.Layer objects. For now there is always at most one member in the array.
Image.Image decode(string data, void|mapping options)
Data is the SVG data, the charset must be unicode.
If options is specified, it contains one or more of the following options
|
Returns the image member of the mapping returned by _decode
| Module Image.PCX |
object decode(string data)
Decodes a PCX image.
Throws upon error in data.
string encode(object image)
string encode(object image, object mappingoptions)
string _encode(object image)
string _encode(object image, object mappingoptions)
Encodes a PCX image. The _encode and the encode functions are identical
The options argument may be a mapping containing zero or more encoding options:
normal options:
"raw":1
Do not RLE encode the image
"dpy":int
"xdpy":int
"ydpy":int
Image resolution (in pixels/inch, integer numbers)
"xoffset":int
"yoffset":int
Image offset (not used by most programs, but gimp uses it)
mapping _decode(string data)
Decodes a PCX image to a mapping.
Throws upon error in data.
| Module Image.PVR |
Handle encoding and decoding of PVR images.
PVR is the texture format of the NEC PowerVR system It is a rather simple, uncompressed, truecolor format.
object decode(string data)
object decode_alpha(string data)
mapping decode_header(string data)
mapping _decode(string data)
decodes a PVR image
The decode_header and _decode has these elements:
"image":object - image object \- not decode_header
"alpha":object - decoded alpha /
"type":"image/x-pvr" - image type
"xsize":int - horisontal size in pixels
"ysize":int - vertical size in pixels
"attr":int - texture attributes
"global_index":int - global index (if present)
string encode(object image)
string encode(object image, mapping options)
encode a PVR image
options is a mapping with optional values:
"alpha":object - alpha channel
"global_index":int - global index
"vq":int(0..1) - Vector Quantification compression
| Module Image.RAS |
This submodule keep the RAS encode/decode capabilities of the Image module.
Image , Image.Image , Image.Colortable
object decode(string data)
Decodes RAS data and creates an image object.
the decoded image as an image object
This function may throw errors upon illegal RAS data.
encode
string encode(object image)
string encode(object image, object mappingoptions)
Encodes a RAS image.
The options argument may be a mapping containing zero or more encoding options:
normal options:
"palette":colortable object
Use this as palette for pseudocolor encoding
| Module Image.BMP |
This submodule keeps the BMP (Windows Bitmap) encode/decode capabilities of the Image module.
BMP is common in the Windows environment.
Simple encoding:
encode
Image , Image.Image , Image.Colortable
object decode(string data)
mapping _decode(string data)
mapping decode_header(string data)
object decode(string data, mapping options)
mapping _decode(string data, mapping options)
mapping decode_header(string data, mapping options)
Decode a BMP.
decode gives an image object,
_decode gives a mapping in the format
"type":"image/x-MS-bmp",
"image":image object,
"colortable":colortable object (if applicable)
"xsize":int,
"ysize":int,
"compression":int,
"bpp":int,
"windows":int,
the encoded image as a string
Doesn't support all BMP modes. At all.
encode
string encode(object image)
string encode(object image, mapping options)
string encode(object image, object colortable)
string encode(object image, int bpp)
Make a BMP. It default to a 24 bpp BMP file, but if a colortable is given, it will be 8bpp with a palette entry.
option is a mapping that may contain:
"colortable": Image.Colortable - palette
"bpp": 1|4|8|24 - force this many bits per pixel
"rle": 0|1 - run-length encode (default is 0)
Source image.
Colortable object, shortcut for "colortable" in options.
the encoded image as a string
Doesn't support old BMP mode, only "windows" mode.
decode
| Module Image.XCF |
object decode(string data)
Decodes a XCF image to a single image object.
Throws upon error in data, you will loose quite a lot of information by doing this. See Image.XCF._decode and Image.XCF.__decode
array(object) decode_layers(object stringdata)
array(object) decode_layers(object stringdata, object mappingoptions)
Decodes a XCF image to an array of Image.Layer objects
The layer object have the following extra variables (to be queried using get_misc_value):
image_xres, image_yres, image_colormap, image_guides, image_parasites, name, parasites, visible, active
Takes the same argument mapping as _decode ,
mapping _decode(string|object data, mapping|void options)
Decodes a XCF image to a mapping, with at least an 'image' and possibly an 'alpha' object. Data is either a XCF image, or a XCF.GimpImage object structure (as received from __decode)
Supported options
([
"background":({r,g,b})||Image.Color object
"draw_all_layers":1,
Draw invisible layers as well
"draw_guides":1,
Draw the guides
"draw_selection":1,
Mark the selection using an overlay
"ignore_unknown_layer_modes":1
Do not asume 'Normal' for unknown layer modes.
"mark_layers":1,
Draw an outline around all (drawn) layers
"mark_layer_names":Image.Font object,
Write the name of all layers using the font object,
"mark_active_layer":1,
Draw an outline around the active layer
])
Throws upon error in data. For more information, see Image.XCF.__decode
object __decode(string|mapping data, object mapping|voidoptions)
Decodes a XCF image to a Image.XCF.GimpImage object.
Returned structure reference
!class GimpImage
{
int width;
int height;
int compression;
int type;
int tattoo_state;
float xres = 72.0;
float yres = 72.0;
int res_unit;
Image.Colortable colormap;
Image.Colortable meta_colormap;
array(Layer) layers = ({});
array(Channel) channels = ({});
array(Guide) guides = ({});
array(Parasite) parasites = ({});
array(Path) paths = ({});
Layer active_layer;
Channel active_channel;
Channel selection;
}
!class Layer
{
string name;
int opacity;
int type;
int mode;
int tattoo;
mapping flags = ([]);
int width, height;
int xoffset, yoffset;
array (Parasite) parasites;
LayerMask mask;
Hierarchy image;
}
!class Channel
{
string name;
int width;
int height;
int opacity;
int r, g, b;
int tattoo;
Hierarchy image_data;
object parent;
mapping flags = ([]);
array (Parasite) parasites;
}
!class Hierarchy
{
Image.Image img;
Image.Image alpha;
int width;
int height;
int bpp;
}
!class Parasite
{
string name;
int flags;
string data;
}
!class Guide
{
int pos;
int vertical;
}
!class Path
{
string name;
int ptype;
int tattoo;
int closed;
int state;
int locked;
array (PathPoint) points = ({});
}
!class PathPoint
{
int type;
float x;
float y;
}
object ___decode(string|mapping data)
Decodes a XCF image to a mapping.
Structure reference
([
"width":int,
"height":int,
"type":int,
"properties":({
([
"type":int,
"data":string,
]),
...
}),
"layers":({
([
"name":string,
"width":int,
"height":int,
"type":type,
"properties":({
([
"type":int,
"data":string,
]),
...
}),
"mask":0 || ([
"name":string,
"width":int,
"height":int,
"properties":({
([
"type":int,
"data":string,
]),
...
}),
"image_data":([
"bpp":int,
"width":int,
"height":int,
"tiles":({
string,
...
}),
]),
]),
"image_data":([
"bpp":int,
"width":int,
"height":int,
"tiles":({
string,
...
}),
]),
]),
...
}),
"channels":({
"name":string,
"width":int,
"height":int,
"properties":({
([
"type":int,
"data":string,
]),
...
}),
"image_data":([
"bpp":int,
"width":int,
"height":int,
"tiles":({
string,
...
}),
]),
}),
])
| Module Image.ILBM |
This submodule keep the ILBM encode/decode capabilities of the Image module.
Image , Image.Image , Image.Colortable
object decode(string data)
object decode(array _decoded)
object decode(array __decoded)
Decodes ILBM data and creates an image object.
the decoded image as an image object
This function may throw errors upon illegal ILBM data. This function uses __decode and _decode internally.
encode
string encode(object image)
string encode(object image, object mappingoptions)
Encodes an ILBM image.
The options argument may be a mapping containing zero or more encoding options:
normal options:
"alpha":image object
Use this image as mask
(Note: ILBM mask is boolean.
The values are calculated by (r+2g+b)/4>=128.)
"palette":colortable object
Use this as palette for pseudocolor encoding
array _decode(string|array data)
Decode an ILBM image file.
Result is a mapping,
([
"image": object image,
... more ...
])
image is the stored image.
array __decode()
Decodes an ILBM image structure down to chunks and
({int xsize,int ysize, // 0: size of image drawing area
string bitmapheader, // 2: BMHD chunk
void|string colortable, // 3: opt. colortable chunk (CMAP)
void|string colortable, // 4: opt. colormode chunk (CAMG)
string body, // 5: BODY chunk
mapping more_chunks}) // 6: mapping with other chunks
the above array
May throw errors if the ILBM header is incomplete or illegal.
| Module Image.ANY |
This method calls the other decoding methods and has some heuristics for what type of image this is.
Methods: decode , decode_alpha , _decode
Image
mapping _decode(string data)
object decode(string data)
object decode_alpha(string data)
Tries heuristics to find the correct method of decoding the data, then calls that method.
The result of _decode() is a mapping that contains
"type":image data type (ie, "image/jpeg" or similar)
"image":the image object,
"alpha":the alpha channel or 0 if N/A
Throws upon failure.
| Module Image.XBM |
object decode(string data)
Decodes a XBM image.
Throws upon error in data.
string encode(object image)
string encode(object image, object mappingoptions)
Encodes a XBM image.
The options argument may be a mapping containing zero or more encoding options.
normal options:
"name":"xbm_image_name"
The name of the XBM. Defaults to 'image'
object _decode(string data)
object _decode(string data, object mappingoptions)
Decodes a XBM image to a mapping.
Supported options:
([
"fg":({fgcolor}), // Foreground color. Default black
"bg":({bgcolor}), // Background color. Default white
"invert":1, // Invert the mask
])
Throws upon error in data.
| Module Image.X |
This submodule handles encoding and decoding of the binary formats of X11.
Image , Image.Image , Image.Colortable
object decode_pseudocolor(string data, int width, int height, int bpp, int alignbits, int swapbytes, object colortable)
lazy support for pseudocolor ZPixmaps
currently, only byte-aligned pixmaps are supported
object decode_truecolor(string data, int width, int height, int bpp, int alignbits, int swapbytes, int rbits, int rshift, int gbits, int gshift, int bbits, int bshift)
object decode_truecolor_masks(string data, int width, int height, int bpp, int alignbits, int swapbytes, int rmask, int gmask, int bmask)
lazy support for truecolor ZPixmaps
currently, only byte-aligned masks are supported
string encode_pseudocolor(object image, int bpp, int alignbits, int vbpp, object colortable)
string encode_pseudocolor(object image, int bpp, int alignbits, int vbpp, object colortable, string translate)
the image object to encode
bits per pixel, how many bits each pixel should take
value bits per pixel; how many bits per pixel that really contains information
the number of even bits each line should be padded to
colortable to get indices for pseudocolor
translate table for colors. Length of this string should be 1<<vbpp (or 2<<vbpp if vbpp are greater than 8).
currently, only upto 16 bits pseudocolor are supported.
string encode_truecolor(object image, int bpp, int alignbits, int swapbytes, int rbits, int rshift, int gbits, int gshift, int bbits, int bshift)
string encode_truecolor_masks(object image, int bpp, int alignbits, int swapbytes, int rmask, int gmask, int bmask)
string encode_truecolor(object image, int bpp, int alignbits, int swapbytes, int rbits, int rshift, int gbits, int gshift, int bbits, int bshift, object ct)
string encode_truecolor_masks(object image, int bpp, int alignbits, int swapbytes, int rmask, int gmask, int bmask, object ct)
Pack an image into a truecolor string. You will get a string of packed red, green and blue bits; ie:
encode_truecolor(img, 12,32, 0, 3,5, 4,0, 3,8)
will give (aligned to even 32 bits for each row):
0bbbrrr0 gggg0bbb rrr0gggg 0bbb...
<--pixel 1--><--pixel 2--> <--3-->
10987654 32101098 76543210 1098... <- bit position
<-><-> <-->
| | +--- 4,0: 4 bits green shifted 0 bits
| +-------- 3,5: 3 bits red shifted 5 bits
+----------- 3,8: 3 bits blue shifted 8 bits
The above call is equal to
encode_truecolor_masks(img, 12,32, 0, 224, 15, 768)
and
encode_truecolor(img, 12,32, 0, 3,5,4,0,3,8, colortable(1<<3,1<<4,1<<3)).
The latter gives possibility to use dither algorithms,
but is slightly slower.
the image object to encode
bits per pixel, how many bits each pixel should take
the number of even bits each line should be padded to
bits for each basecolor
leftshifts for each basecolor
masks for each basecolor (xbits and gbits are calculated from this), needs to be massive (no zeroes among the ones in the mask).
colortable object (for dithering, or whatever)
swap bytes for bpp==16,24,32, swaps bits in the bytes if bpp==1, for change of byte/bitorder between client and server.
| Module Image.WBMP |
WAP bitmap format - WBMP.
object decode(string image)
Document this function.
mapping _decode(string image)
Document this function.
mapping decode_header(string image)
|
string encode(object image, void|mapping args)
string _encode(object image, void|mapping args)
Document this function.
| Module Image.PNM |
This submodule keeps the PNM encode/decode capabilities of the Image module.
PNM is a common image storage format on unix systems, and is a very simple format.
This format doesn't use any color palette.
The format is divided into seven subformats;
P1(PBM) - ascii bitmap (only two colors)
P2(PGM) - ascii greymap (only grey levels)
P3(PPM) - ascii truecolor
P4(PBM) - binary bitmap
P5(PGM) - binary greymap
P6(PPM) - binary truecolor
Simple encoding:
encode ,
encode_binary ,
encode_ascii
Simple decoding:
decode
Advanced encoding:
encode_P1 ,
encode_P2 ,
encode_P3 ,
encode_P4 ,
encode_P5 ,
encode_P6
Image , Image.Image , Image.GIF
object decode(string data)
Decodes PNM (PBM/PGM/PPM) data and creates an image object.
the decoded image as an image object
This function may throw errors upon illegal PNM data.
encode
string encode(object image)
string encode_binary(object image)
string encode_ascii(object image)
string encode_P1(object image)
string encode_P2(object image)
string encode_P3(object image)
string encode_P4(object image)
string encode_P5(object image)
string encode_P6(object image)
Make a complete PNM file from an image.
encode_binary () and encode_ascii () uses the most optimized encoding for this image (bitmap, grey or truecolor) - P4, P5 or P6 respective P1, P2 or P3.
encode_P1 /encode_P4
assumes the image is black and white. Use
Image.Image->threshold () or something like
Image.Colortable ( ({({0,0,0}),({255,255,255})}) )
->floyd_steinberg()
->map(my_image)
to get a black and white image.
encode_P2 /encode_P5 assumes the image is greyscale. Use Image.Image->grey () to get a greyscale image.
the encoded image as a string
encode () is equal to encode_binary (), but may change in a future release.
decode
| Module Image.TIM |
Handle decoding of TIM images.
TIM is the framebuffer format of the PSX game system. It is a simple, uncompressed, truecolor or CLUT format with a one bit alpha channel.
object decode(string data)
object decode_alpha(string data)
mapping decode_header(string data)
mapping _decode(string data)
decodes a TIM image
The decode_header and _decode has these elements:
"image":object - image object \- not decode_header
"alpha":object - decoded alpha /
"type":"image/x-tim" - image type
"xsize":int - horisontal size in pixels
"ysize":int - vertical size in pixels
"attr":int - texture attributes
| Module Image.NEO |
Decodes images from the Atari image editor Neochrome.
mapping _decode(string data)
Low level decoding of the NEO file contents in data .
|
Image.Image decode(string data)
Decodes the image data into an Image.Image object.
| Module Image._XPM |
int(0..0) _xpm_write_rows(Image.Image img, Image.Image alpha, int bpc, array(string) colors, array(string) pixels)
Fills in img and alpha according to xpm data in bpc , colors and pixels .
Bytes per color. Number of bytes used to encode each color in pixels .
Array of color definitions.
A color definition is on the format "ee c #RRGGBB", where ee is a bpc long string used to encode the color, c is a literal "c", and RRGGBB is a hexadecimal RGB code.
Raw picture information.
| ||||||||
array(string) _xpm_trim_rows(array(string) rows)
| Module Image.AVS |
object decode(string data)
mapping _decode(string data)
string encode(object image)
Handle encoding and decoding of AVS-X images. AVS is rather trivial, and not really useful, but:
An AVS file is a raw (uncompressed) 24 bit image file with alpha. The alpha channel is 8 bit, and there is no separate alpha for r, g and b.
| Module Image.TGA |
object decode(string data)
Decodes a Targa image.
Throws upon error in data.
string encode(object image)
string encode(object image, object mappingoptions)
Encodes a Targa image.
The options argument may be a mapping containing zero or more encoding options:
normal options:
"alpha":image object
Use this image as alpha channel
(Note: Targa alpha channel is grey.
The values are calculated by (r+2g+b)/4.)
"raw":1
Do not RLE encode the image
object _decode(string data)
Decodes a Targa image to a mapping. The mapping follows this format: ([ "image":img_object, "alpha":alpha_channel ])
Throws upon error in data.
| Module Image.XWD |
This submodule keeps the XWD (X Windows Dump) decode capabilities of the Image module.
XWD is the output format for the xwd program.
Simple decoding:
decode
Advanced decoding:
_decode
Image , Image.Image , Image.PNM , Image.X
object decode(string data)
Simple decodes a XWD image file.
mapping _decode(string data)
mapping decode_header(string data)
Decodes XWD data and returns the result.
Supported XWD visual classes and encoding formats are TrueColor / ZPixmap DirectColor / ZPixmap PseudoColor / ZPixmap
If someone sends me files of other formats, these formats may be implemented. :) /mirar+pike@mirar.org
the decoded image as an image object
This function may throw errors upon illegal or unknown XWD data.
decode
| Module Image.HRZ |
object decode(string data)
mapping _decode(string data)
string encode(object image)
Handle encoding and decoding of HRZ images. HRZ is rather trivial, and not really useful, but:
The HRZ file is always 256x240 with RGB values from 0 to 63. No compression, no header, just the raw RGB data. HRZ is (was?) used for amatuer radio slow-scan TV.
| Module Image.PNG |
Support for encoding and decoding the Portable Network Graphics format, PNG.
This module uses zlib.
string _chunk(string type, string data)
Encodes a PNG chunk.
Please read about the PNG file format.
array __decode(string data)
array __decode(string data, int dontcheckcrc)
Splits a PNG file into chunks.
Result is an array of arrays, or 0 if data isn't a PNG file. Each element in the array is constructed as follows.
| ||||||||
Please read about the PNG file format. Support for decoding cHRM, gAMA, sBIT, hIST, pHYs, tIME, tEXt and zTXt chunks are missing.
mapping _decode(string|array data)
mapping _decode(string|array data, mapping options)
Decode a PNG image file.
|
|
Throws an error if the image data is erroneous.
Please read about the PNG file format. This function ignores any checksum errors in the file. A PNG of higher color resolution than the Image module supports (8 bit) will lose that information in the conversion.
string encode(Image.Image image)
string encode(Image.Image image, mapping options)
Encodes a PNG image.
|
__decode
Please read some about PNG files.
mapping decode_header(string data)
Decodes only the PNG headers.
_decode
Image.Image decode(string data)
Image.Image decode(string data, mapping(string:mixed) options)
Decodes a PNG image. The options mapping is the as for _decode .
Throws upon error in data.
Image.Image decode_alpha(string data, void|mapping(string:mixed) options)
Decodes the alpha channel in a PNG file. The options mapping is the same as for _decode .
Throws upon error in data.
| Module Image.Color |
This module keeps names and easy handling for easy color support. It gives you an easy way to get colors from names.
A color is here an object, containing color information and methods for conversion, see below.
Image.Color can be called to make a color object.
Image.Color() takes the following arguments:
Image.Color(string name) // "red"
Image.Color(string prefix_string) // "lightblue"
Image.Color(string hex_name) // "#ff00ff"
Image.Color(string cmyk_string) // "%17,42,0,19.4"
Image.Color(string hsv_string) // "%@327,90,32"
Image.Color(int red, int green, int blue)
The color names available can be listed by using indices
on Image.Color. The colors are available by name directly
as Image.Color.name, too:
...Image.Color.red...
...Image.Color.green...
or, maybe
import Image.Color;
...red...
...green...
...lightgreen...
Giving red, green and blue values is equal to calling Image.Color.rgb ().
The prefix_string method is a form for getting modified colors, it understands all modifiers (light , dark , bright , dull and neon ). Simply use "method"+"color"; (as in lightgreen, dullmagenta, lightdullorange).
The hex_name form is a simple #rrggbb form, as in HTML or X-program argument. A shorter form (#rgb) is also accepted. This is the inverse to the Image.Color.Color->hex () method.
The cmyk_string is a string form of giving cmyk (cyan, magenta, yellow, black) color. These values are floats representing percent.
The hsv_string is another hue, saturation, value representation, but in floats; hue is in degree range (0..360), and saturation and value is given in percent. This is not the same as returned or given to the hsv () methods!
This table lists all the different named colors available in Image.Color. The first column shows the actual color while the five following columns demonstrates the modifiers neon, light, dark, bright and dull. The color begind the name of the color is produced by calling neon()->dark()->dark()->dark() from the color object itself, i.e. Image.Color.mintcream->neon()->dark()->dark()->dark().

























































Image.Color["something"] will never(!) generate an error, but a zero_type 0, if the color is unknown. This is enough to give the error "not present in module", if used as Image.Color.something, though.
If you are using colors from for instance a webpage, you might want to create the color from Image.Color.guess (), since that method is more tolerant for mistakes and errors.
Image.Color() is case- and space-sensitive. Use Image.Color.guess () to catch all variants.
and subtract with a space (lower_case(x)-" ") to make sure you get all variants.
Image.Color.Color , Image.Color.guess , Image , Image.Colortable
object rgb(int red, object intgreen, object intblue)
object hsv(int hue, object intsaturation, object intvalue)
object cmyk(float c, float m, float y, float k)
object greylevel(int level)
object html(string html_color)
Creates a new color object from given red, green and blue, hue, saturation and value, or greylevel, in color value range. It could also be created from cmyk values in percent.
The html () method only understands the HTML color names, or the #rrggbb form. It is case insensitive.
the created object.
object guess(string color)
This is equivalent to Image.Color (lower_case(str)-" "), and tries the color with a prepending '#' if no corresponding color is found.
a color object or zero_type
array(string) _indices()
array(object) _values()
(ie as indices(Image.Color) or values(Image.Color)) indices gives a list of all the known color names, values gives there corresponding objects.
Image.Color
| CLASS Image.Color.Color |
This is the color object. It has six readable variables, r, g, b, for the red, green and blue values, and h, s, v, for the hue, saturation anv value values.
int bits(object intrbits, object intgbits, object intbbits, object intrshift, object intgshift, object intbshift)
Returns the color as an integer. The first three parameters state how many bits to use for red, green and blue respectively. The last three state how many bits each colour should be shifted. For instance, Image.Color("#AABBCC")->bits(8, 8, 8, 16, 8, 0) returns the integer 11189196, that is, 0xAABBCC.
object light()
object dark()
object neon()
object bright()
object dull()
Color modification methods. These returns a new color.
| method | effect | h | s | v | as |
|---|---|---|---|---|---|
| light | raise light level | ±0 | ±0 | +50 | |
| dark | lower light level | ±0 | ±0 | -50 | |
| bright | brighter color | ±0 | +50 | +50 | |
| dull | greyer color | ±0 | -50 | -50 | |
| neon | set to extreme | ±0 | max | max |
light and dark lower/highers saturation when value is min-/maximised respective.
the new color object
The opposites may not always take each other out. The color is maximised at white and black levels, so, for instance Image.Color .white->light ()->dark () doesn't give the white color back, but the equal to Image.Color .white->dark (), since white can't get any light er.
array|string cast()
cast the object to an array, representing red, green and blue (equal to ->rgb ()), or to a string, giving the name (equal to ->name ()).
the name as string or rgb as array
rgb , name
array(int) rgb()
array(float) rgbf()
array(int) hsv()
array(float) hsvf()
array(float) cmyk()
int greylevel()
int greylevel(int r, object intg, object intb)
This is methods of getting information from an Image.Color.Color object.
They give an array of
red, green and blue (rgb) values (color value),
hue, saturation and value (hsv) values (range as color value),
cyan, magenta, yellow, black (cmyk) values (in percent)
or the greylevel value (range as color value).
The greylevel is calculated by weighting red, green and blue. Default weights are 87, 127 and 41, respective, and could be given by argument.
array(int) respective int
Image.Color.Color , grey
void Image.Color.Color(int r, int g, int b)
This is the main Image.Color.Color creation method, mostly for internal use.
object grey()
object grey(int red, int green, int blue)
Gives a new color, containing a grey color, which is calculated by the greylevel method.
a new Image.Color.Color object
greylevel
string hex()
string hex(int n)
string name()
string html()
Information methods.
hex () simply gives a string on the #rrggbb format. If n is given, the number of significant digits is set to this number. (Ie, n=3 gives #rrrgggbbb.)
name () is a simplified method; if the color exists in the database, the name is returned, per default is the hex () method use.
html () gives the HTML name of the color, or the hex (2) if it isn't one of the 16 HTML colors.
a new Image.Color.Color object
rgb , hsv , Image.Color
int `==(object other_color)
int `==(array(int) rgb)
int `==(int greylevel)
int `==(string name)
Compares this object to another color,
or color name. Example:
object red=Image.Color.red;
object other=Image.Color. ...;
object black=Image.Color.black;
if (red==other) ...
if (red==({255,0,0})) ...
if (black==0) ...
if (red=="red") ...
1 or 0
The other datatype (not color object) must be to the right!
rgb , grey , name
| Module Image.JPEG |
This module uses libjpeg, a software from Independent JPEG Group.
string encode(object image)
string encode(string|object image, mapping options)
Encodes an image object with JPEG compression. The image may also be a string containing a raw JPEG image. In the The options argument may be a mapping containing zero or more encoding options:
|
Please read some about JPEG files. A quality setting of 100 does not mean the result is lossless.
object decode(string data)
object decode(string data, mapping options)
mapping _decode(string data)
mapping _decode(string data, mapping options)
mapping decode_header(string data)
Decodes a JPEG image. The simple decode function simply gives the image object, the other functions gives a mapping of information (see below).
The options argument may be a mapping containing zero or more decoding options:
|
_decode and decode_header gives a mapping as result, with this content:
|
mapping(int:array(array(int))) quant_tables(int|void a)
Document this function
constant Image.JPEG.IFAST
constant Image.JPEG.FLOAT
constant Image.JPEG.DEFAULT
constant Image.JPEG.ISLOW
constant Image.JPEG.FASTEST
constant Image.JPEG.FLIP_H
constant Image.JPEG.FLIP_V
constant Image.JPEG.ROT_90
constant Image.JPEG.ROT_180
constant Image.JPEG.ROT_270
constant Image.JPEG.TRANSPOSE
constant Image.JPEG.TRANSVERSE
| CLASS Image.JPEG.Marker |
constant Image.JPEG.Marker.EOI
constant Image.JPEG.Marker.RST0
constant Image.JPEG.Marker.COM
constant Image.JPEG.Marker.APP0
constant Image.JPEG.Marker.APP1
constant Image.JPEG.Marker.APP2
constant Image.JPEG.Marker.APP3
constant Image.JPEG.Marker.APP4
constant Image.JPEG.Marker.APP5
constant Image.JPEG.Marker.APP6
constant Image.JPEG.Marker.APP7
constant Image.JPEG.Marker.APP8
constant Image.JPEG.Marker.APP9
constant Image.JPEG.Marker.APP10
constant Image.JPEG.Marker.APP11
constant Image.JPEG.Marker.APP12
constant Image.JPEG.Marker.APP13
constant Image.JPEG.Marker.APP14
constant Image.JPEG.Marker.APP15
| Module Image.FreeType |
Pike glue for the FreeType2 library, http://www.freetype.org/
constant Image.FreeType.FACE_FLAG_SCALABLE
constant Image.FreeType.FACE_FLAG_FIXED_WIDTH
constant Image.FreeType.FACE_FLAG_SFNT
constant Image.FreeType.FACE_FLAG_HORIZONTAL
constant Image.FreeType.FACE_FLAG_VERTICAL
constant Image.FreeType.FACE_FLAG_KERNING
constant Image.FreeType.FACE_FLAG_FAST_GLYPHS
constant Image.FreeType.FACE_FLAG_MULTIPLE_MASTERS
constant Image.FreeType.FACE_FLAG_GLYPH_NAMES
constant Image.FreeType.STYLE_FLAG_ITALIC
constant Image.FreeType.STYLE_FLAG_BOLD
| CLASS Image.FreeType.Face |
A FreeType font face. We recommend using the more generic font handling interfaces in Image.Fonts instead.
Image.Image write_char(int char)
int get_kerning(int l, int r)
void attach_file(string file)
Face set_size(int width, int height)
array(string) list_encodings()
void select_encoding(string|int encoding)
mapping info()
|
void Image.FreeType.Face(string font)
The path of the font file to use
| Module Image.TTF |
This module adds TTF (Truetype font) capability to the Image module.
This module needs the libttf "Freetype" library
object `()(string filename)
object `()(string filename, mapping options)
Makes a new TTF Face object.
The filename of the TTF font or the TTC font collection.
advanced options:
"face":int
If opening a font collection, '.TTC',
this is used to get other fonts than the first.
0 if failed.
| CLASS Image.TTF.Face |
This represents instances of TTF Faces.
object flush()
This flushes all cached information. Might be used to save memory - the face information is read back from disk upon need.
the object being called
mapping names()
array(array) _names()
Gives back the names or the complete name-list of this face.
The result from names () is a mapping,
which has any or all of these indices:
"copyright": ("Copyright the Foo Corporation...bla bla")
"family": ("My Little Font")
"style": ("Bold")
"full": ("Foo: My Little Font: 1998")
"expose": ("My Little Font Bold")
"version": ("June 1, 1998; 1.00, ...")
"postscript": ("MyLittleFont-Bold")
"trademark": ("MyLittleFont is a registered...bla bla")
This is extracted from the information from _names(), and fit into pike-strings using unicode or iso-8859-1, if possible.
The result from _names () is a
matrix, on this form:
({ ({ int platform, encoding, language, id, string name }),
({ int platform, encoding, language, id, string name }),
...
})
the name as a mapping to string or the names as a matrix
To use the values from _names (), check the TrueType standard documentation.
mapping properties()
This gives back a structure of the face's properties. Most of this stuff is information you can skip.
The most interesting item to look at may be ->num_Faces, which describes the number of faces in a .TTC font collection.
a mapping of a lot of properties
object `()()
This instantiates the face for normal usage - to convert font data to images.
a Image.TTF.FaceInstance object.
| CLASS Image.TTF.FaceInstance |
This is the instance of a face, with geometrics, encodings and stuff.
void Image.TTF.FaceInstance(object face)
creates a new Instance from a face.
| Module Image.TIFF |
object decode(string data)
Decodes a TIFF image.
Throws upon error in data.
mapping(string:mixed) _decode(string data)
Decodes a TIFF image to a mapping with at least the members image and alpha.
|
Throws upon error in data.
string encode(object image)
string encode(object image, mapping options)
string _encode(object image)
string _encode(object image, mapping options)
Encode an image object into a TIFF file. [encode] and _encode are identical.
The options argument may be a mapping containing zero or more encoding options. See _decode .
Image.TIFF.encode(img, ([ "compression":Image.TIFF.COMPRESSION_LZW, "name":"an image name", "comment":"an image comment", "alpha":An alpha channel, "dpy":Dots per inch (as a float), "xdpy":Horizontal dots per inch (as a float), "ydpy":Vertical dots per inch (as a float), ]));
constant Image.TIFF.COMPRESSION_NONE
constant Image.TIFF.COMPRESSION_CCITTRLE
constant Image.TIFF.COMPRESSION_CCITTFAX3
constant Image.TIFF.COMPRESSION_CCITTFAX4
constant Image.TIFF.COMPRESSION_CCITTRLEW
constant Image.TIFF.COMPRESSION_LZW
constant Image.TIFF.COMPRESSION_JPEG
constant Image.TIFF.COMPRESSION_NEXT
constant Image.TIFF.COMPRESSION_PACKBITS
constant Image.TIFF.COMPRESSION_THUNDERSCAN
| Module Image.XFace |
This module uses libgmp.
object decode(string data)
object decode(string data, object mappingoptions)
Decodes an X-Face image.
The options argument may be a mapping containing zero options.
object decode_header(string data)
object decode_header(string data, object mappingoptions)
Decodes an X-Face image header.
"xsize":int
"ysize":int
size of image
"type":"image/x-xface"
file type information
The options argument may be a mapping containing zero options.
There aint no such thing as a X-Face image header. This stuff tells the characteristics of an X-Face image.
string encode(object img)
string encode(object img, object mappingoptions)
Encodes an X-Face image.
The img argument must be an image of the dimensions 48 by 48 pixels. All non-black pixels will be considered white.
The options argument may be a mapping containing zero options.
| Module Image.GIF |
This submodule keep the GIF encode/decode capabilities of the Image module.
GIF is a common image storage format, usable for a limited color palette - a GIF image can only contain as most 256 colors - and animations.
Simple encoding: encode , encode_trans
Advanced stuff: render_block , header_block , end_block , netscape_loop_block
Very advanced stuff: _render_block , _gce_block
Image , Image.Image , Image.Colortable
object decode(string data)
object decode(array _decoded)
object decode(array __decoded)
Decodes GIF data and creates an image object.
the decoded image as an image object
This function may throw errors upon illegal GIF data. This function uses __decode , _decode , Image.Image->paste and Image.Image->paste_alpha internally.
encode
object decode_layers(string data)
object decode_layers(array _decoded)
object decode_layer(string data)
object decode_layer(array _decoded)
Decodes GIF data and creates an array of layers or the resulting layer.
The resulting layer may not have the same size as the gif image, but the resulting bounding box of all render chunks in the gif file. The offset should be correct, though.
encode , decode_map
mapping decode_map(string|array layers)
Returns a mapping similar to other decoders _decode function.
"image":the image
"alpha":the alpha channel
"xsize":int
"ysize":int
size of image
"type":"image/gif"
file type information as MIME type
The weird name of this function (not _decode as the other decoders) is because gif was the first decoder and was written before the API was finally defined. Sorry about that. /Mirar
string encode(object img)
string encode(object img, int colors)
string encode(object img, object colortable)
string encode_trans(object img, object alpha)
string encode_trans(object img, int tr_r, int tr_g, int tr_b)
string encode_trans(object img, int colors, object alpha)
string encode_trans(object img, int colors, int tr_r, int tr_g, int tr_b)
string encode_trans(object img, int colors, object alpha, int tr_r, int tr_g, int tr_b)
string encode_trans(object img, object colortable, object alpha)
string encode_trans(object img, object colortable, int tr_r, int tr_g, int tr_b)
string encode_trans(object img, object colortable, object alpha, int a_r, int a_g, int a_b)
string encode_trans(object img, object colortable, int transp_index)
Create a complete GIF file.
The latter (encode_trans ) functions add transparency capabilities.
Example:
img=Image.Image ([...]);
[...] // make your very-nice image
write(Image.GIF.encode (img)); // write it as GIF on stdout
The image which to encode.
These arguments decides what colors the image should be encoded with. If a number is given, a colortable with be created with (at most) that amount of colors. Default is '256' (GIF maximum amount of colors).
Alpha channel image (defining what is transparent); black
color indicates transparency. GIF has only transparent
or nontransparent (no real alpha channel).
You can always dither a transparency channel:
Image.Colortable(my_alpha, ({({0,0,0}),({255,255,255})}))
->full()
->floyd_steinberg()
->map(my_alpha)
Use this (or the color closest to this) color as transparent pixels.
Encode transparent pixels (given by alpha channel image) to have this color. This option is for making GIFs for the decoders that doesn't support transparency.
Use this color no in the colortable as transparent color.
For advanced users:
Image.GIF.encode_trans(img,colortable,alpha);
is equivalent of using
Image.GIF.header_block(img->xsize(),img->ysize(),colortable)+
Image.GIF.render_block(img,colortable,0,0,0,alpha)+
Image.GIF.end_block();
and is actually implemented that way.
string end_block()
This function gives back a GIF end (trailer) block.
the end block as a string.
This is in the advanced sector of the GIF support; please read some about how GIFs are packed.
The result of this function is always ";" or "\x3b", but I recommend using this function anyway for code clearity.
header_block , end_block
string header_block(int xsize, int ysize, int numcolors)
string header_block(int xsize, int ysize, object colortable)
string header_block(int xsize, int ysize, object colortable, int background_color_index, int gif87a, int aspectx, int aspecty)
string header_block(int xsize, int ysize, object colortable, int background_color_index, int gif87a, int aspectx, int aspecty, int r, int g, int b)
This function gives back a GIF header block.
Giving a colortable to this function includes a global palette in the header block.
Size of drawing area. Usually same size as in the first (or only) render block(s).
This color in the palette is the background color. Background is visible if the following render block(s) doesn't fill the drawing area or are transparent. Most decoders doesn't use this value, though.
If set, write 'GIF87a' instead of 'GIF89a' (default 0 == 89a).
Aspect ratio of pixels, ranging from 4:1 to 1:4 in increments of 1/16th. Ignored by most decoders. If any of aspectx or aspecty is zero, aspectratio information is skipped.
Add this color as the transparent color. This is the color used as transparency color in case of alpha-channel given as image object. This increases (!) the number of colors by one.
the created header block as a string
This is in the advanced sector of the GIF support; please read some about how GIFs are packed.
This GIF encoder doesn't support different size of colors in global palette and color resolution.
header_block , end_block
string netscape_loop_block()
string netscape_loop_block(int number_of_loops)
Creates a application-specific extention block; this block makes netscape and compatible browsers loop the animation a certain amount of times.
Number of loops. Max and default is 65535.
string render_block(object img, object colortable, int x, int y, int localpalette)
string render_block(object img, object colortable, int x, int y, int localpalette, object alpha)
string render_block(object img, object colortable, int x, int y, int localpalette, object alpha, int r, int g, int b)
string render_block(object img, object colortable, int x, int y, int localpalette, int delay, int transp_index, int interlace, int user_input, int disposal)
string render_block(object img, object colortable, int x, int y, int localpalette, object alpha, int r, int g, int b, int delay, int interlace, int user_input, int disposal)
This function gives a image block for placement in a GIF file, with or without transparency. The some options actually gives two blocks, the first with graphic control extensions for such things as delay or transparency.
Example:
img1=Image.Image ([...]);
img2=Image.Image ([...]);
[...] // make your very-nice images
nct=Image.Colortable ([...]); // make a nice colortable
write(Image.GIF.header_block (xsize,ysize,nct)); // write a GIF header
write(Image.GIF.render_block (img1,nct,0,0,0,10)); // write a render block
write(Image.GIF.render_block (img2,nct,0,0,0,10)); // write a render block
[...]
write(Image.GIF.end_block ()); // write end block
// voila! A GIF animation on stdout.
The above animation is thus created:
object nct=Image.Colortable(lena,32,({({0,0,0})}));
string s=GIF.header_block(lena->xsize(),lena->ysize(),nct);
foreach ( ({lena->xsize(),
(int)(lena->xsize()*0.75),
(int)(lena->xsize()*0.5),
(int)(lena->xsize()*0.25),
(int)(1),
(int)(lena->xsize()*0.25),
(int)(lena->xsize()*0.5),
(int)(lena->xsize()*0.75)}),int xsize)
{
object o=lena->scale(xsize,lena->ysize());
object p=lena->clear(0,0,0);
p->paste(o,(lena->xsize()-o->xsize())/2,0);
s+=Image.GIF.render_block(p,nct,0,0,0,25);
}
s+=Image.GIF.netscape_loop_block(200);
s+=Image.GIF.end_block();
write(s);
The image.
Colortable with colors to use and to write as palette.
Position of this image.
If set, writes a local palette.
Alpha channel image; black is transparent.
Color of transparent pixels. Not all decoders understands transparency. This is ignored if localpalette isn't set.
View this image for this many centiseconds. Default is zero.
Index of the transparent color in the colortable. -1 indicates no transparency.
If set: wait the delay or until user input. If delay is zero, wait indefinitely for user input. May sound the bell upon decoding. Default is non-set.
Disposal method number;
This is in the advanced sector of the GIF support; please read some about how GIFs are packed.
The user_input and disposal method are unsupported in most decoders.
encode , header_block , end_block
array _decode(string gifdata)
array _decode(array __decoded)
Decodes a GIF image structure down to chunks, and also decode the images in the render chunks.
({int xsize,int ysize, // 0: size of image drawing area
void|object colortable, // 2: opt. global colortable
({ int aspx, int aspy, // 3 0: aspect ratio or 0, 0 if not set
int background }), // 2: index of background color
followed by any number these blocks in any order (gce chunks
are decoded and incorporated in the render chunks):
({ GIF.RENDER, // 0: block identifier
int x, int y, // 1: position of render
object image, // 3: render image
void|object alpha, // 4: 0 or render alpha channel
object colortable, // 5: colortable (may be same as global)
int interlace, // 6: interlace flag
int trans_index, // 7: 0 or transparent color index
int delay, // 8: 0 or delay in centiseconds
int user_input, // 9: user input flag
int disposal}) // 10: disposal method number (0..7)
({ GIF.EXTENSION, // 0: block identifier
int extension, // 1: extension number
string data }) // 2: extension data
and possibly ended with one of these:
({ GIF.ERROR_PREMATURE_EOD }) // premature end-of-data
({ GIF.ERROR_TOO_MUCH_DATA, // data following end marker
string data }) // (rest of file)
({ GIF.ERROR_UNKNOWN_DATA, // unknown data
string data }) // (rest of file)
The decode method uses this data in a way similar to this program:
import Image;
object my_decode_gif(string data)
{
array a=GIF._decode(data);
object img=image(a[0],a[1]);
foreach (a[4..],array b)
if (b[0]==GIF.RENDER)
if (b[4]) img->paste_alpha(b[3],b[4],b[1],b[2]);
else img->paste(b[3],b[1],b[2]);
return img;
}
GIF data (with header and all)
GIF data as from __decode
the above array
May throw errors if the GIF header is incomplete or illegal.
This is in the very advanced sector of the GIF support; please read about how GIF files works.
string _encode(array data)
Encodes GIF data; reverses _decode.
data as returned from _encode
Some given values in the array are ignored. This function does not give the _exact_ data back!
string _gce_block(int transparency, int transparency_index, int delay, int user_input, int disposal)
This function gives back a Graphic Control Extension block. A GCE block has the scope of the following render block.
The following image has transparency, marked with this index.
View the following rendering for this many centiseconds (0..65535).
Wait the delay or until user input. If delay is zero, wait indefinitely for user input. May sound the bell upon decoding.
Disposal method number;
This is in the very advanced sector of the GIF support; please read about how GIF files works.
Most decoders just ignore some or all of these parameters.
_render_block , render_block
string _render_block(int x, int y, int xsize, int ysize, int bpp, string indices, 0|string colortable, int interlace)
Advanced (!) method for writing renderblocks for placement in a GIF file. This method only applies LZW encoding on the indices and makes the correct headers.
Position of this image.
Size of the image. Length if the indices string must be xsize*ysize.
Bits per pixels in the indices. Valid range 1..8.
The image indices as an 8bit indices.
Colortable with colors to write as palette. If this argument is zero, no local colortable is written. Colortable string len must be 1<<bpp.
Interlace index data and set interlace bit. The given string should _not_ be pre-interlaced.
This is in the very advanced sector of the GIF support; please read about how GIF files works.
encode , _encode , header_block , end_block
array __decode()
Decodes a GIF image structure down to chunks and
({int xsize,int ysize, // 0: size of image drawing area
int numcol, // 2: suggested number of colors
void|string colortable, // 3: opt. global colortable
({ int aspx, int aspy, // 4,0: aspect ratio or 0, 0 if not set
int background }), // 1: index of background color
followed by any number these blocks in any order:
({ GIF.EXTENSION, // 0: block identifier
int extension, // 1: extension number
string data }) // 2: extension data
({ GIF.RENDER, // 0: block identifier
int x, int y, // 1: position of render
int xsize, int ysize, // 3: size of render
int interlace, // 5: interlace flag
void|string colortbl, // 6: opt. local colortable
int lzwsize, // 7: lzw code size
string lzwdata }) // 8: packed lzw data
and possibly ended with one of these:
({ GIF.ERROR_PREMATURE_EOD }) // premature end-of-data
({ GIF.ERROR_TOO_MUCH_DATA, // data following end marker
string data }) // (rest of file)
({ GIF.ERROR_UNKNOWN_DATA, // unknown data
string data }) // (rest of file)
the above array
May throw errors if the GIF header is incomplete or illegal.
This is in the very advanced sector of the GIF support; please read about how GIF files works.
| Module Image.Fonts |
Abstracted Font-handling support. Should be used instead of accessing the FreeType, TTF and Image.Font modules directly.
constant Image.Fonts.ITALIC
The font is/should be italic
constant Image.Fonts.BOLD
The font is/should be bold
constant Image.Fonts.NO_FAKE
Used in open_font () to specify that no fake bold or italic should be attempted.
Font open_font(string fontname, int size, int flags, int|void force)
Find a suitable font in the directories specified with set_font_dirs .
flags is a bitwise or of 0 or more of ITALIC , BOLD and NO_FAKE .
fontname is the human-readable name of the font.
If force is true, a font is always returned (defaulting to arial or the pike builtin font), even if no suitable font is found.
mapping list_fonts()
Returns a list of all the fonts as a mapping.
void set_font_dirs(array(string) directories)
Set the directories where fonts can be found.
| CLASS Image.Fonts.Font |
The abstract Font class. The file is a valid font-file, size is in pixels, but the size of the characters to be rendered, not the height of the finished image (the image is generally speaking bigger then the size of the characters).
protected string Image.Fonts.Font.file
protected int Image.Fonts.Font.sizevoid Image.Fonts.Font(string file, int size)
int set_fake_bold(int fb)
The amount of 'boldness' that should be added to the font when text is rendered.
int set_fake_italic(int(0..1) fi)
If true, make the font italic.
array(int) text_extents(string ... lines)
Returns ({ xsize, ysize }) of the image that will result if lines is sent as the argument to write .
mapping info()
Returns some information about the font. Always included: file: Filename specified when the font was opened size: Size specified when the font was opened family: Family name style: Bitwise or of the style flags, i.e. ITALIC and BOLD .
Image.Image write(string ... line)
Render the text strings sent as line as an alpha-channel image.
| Module Image.Dims |
Reads the dimensions of images of various image formats without decoding the actual image.
array(int) get_JPEG(Stdio.File f)
Reads the dimensions from a JPEG file and returns an array with width and height, or if the file isn't a valid image, 0.
array(int) get_GIF(Stdio.File f)
Reads the dimensions from a GIF file and returns an array with width and height, or if the file isn't a valid image, 0.
array(int) get_PNG(Stdio.File f)
Reads the dimensions from a PNG file and returns an array with width and height, or if the file isn't a valid image, 0.
array(int) get_TIFF(Stdio.File f)
Reads the dimensions from a TIFF file and returns an array with width and height, or if the file isn't a valid image, 0.
array(int) get(string|Stdio.File file)
Read dimensions from a JPEG, GIF, PNG or TIFF file and return an array
with width and height, or if the file isn't a valid image,
0. The argument file should be file object or the data
from a file. The offset pointer will be assumed to be at the start
of the file data and will be modified by the function.
As a compatibility measure, if the file is a path to an image file, it will be loaded and processed once the processing of the path as data has failed.
| ||||||||
| Module Image.PS |
Codec for the Adobe page description language PostScript. Uses Ghostscript for decoding or built-in support.
object decode(string data, mapping|void options)
Decodes the postscript data into an image object using Ghostscript.
Optional decoding parameters.
|
Some versions of gs on MacOS X have problems with reading files on stdin. If this occurrs, try writing to a plain file and specifying the file option.
gs versions 7.x and earlier don't support rendering of EPSes if they are specified with the file option. If this is a problem, upgrade to gs version 8.x or later.
mapping _decode(string data, mapping|void options)
Calls decode and returns the image in the "image" index of the mapping. This method is present for API reasons.
string encode(object img, mapping|void options)
Encodes the image object img as a postscript 3.0 file.
Optional extra encoding parameters.
|
function Image.PS._encode
Same as encode. Present for API reasons.
| Module Image.PSD |
mapping __decode(string|mapping data)
Decodes a PSD image to a mapping, defined as follows.
|
The resources mapping. Unknown resources will be identified by their ID number (as an int).
|
The layer mapping:
|
array(Image.Layer) decode_layers(string data, mapping|void options)
Decodes a PSD image to an array of Image.Layer objects
Takes the same aptions mapping as _decode , note especially "draw_all_layers":1, but implements "crop_to_bounds" which preserves the bounding box for the whole image (i.e. discards data that extend outside of the global bounds).
The layer object have the following extra variables (to be queried using Image.Layer()->get_misc_value ):
|
mapping _decode(string|mapping data, mapping|void options)
Decodes a PSD image to a mapping, with at least an 'image' and possibly an 'alpha' object. Data is either a PSD image, or a mapping (as received from __decode )
|
|
Throws upon error in data. For more information, see __decode
Image.Image decode(string data)
Decodes a PSD image to a single image object.
Throws upon error in data. To get access to more information like alpha channels and layer names, see _decode and __decode .
| Module Image.DWG |
This module decodes the thumbnail raster images embedded in AutoCAD DWG files for AutoCAD version R13, R14 and R2000 (which equals to file version 12, 14 and 15). Implemented according to specifications from http://www.opendwg.org/.
mapping __decode(string data)
Decodes the DWG data into a mapping.
|
This functions throws an error when decoding somehow fails.
mapping _decode(string data)
Works like __decode , but in addition it has the element "image" in the result mapping, containing the first successfully decoded bitmap image. to the result of decode(data).
If no preview was stored, or no preview could be decoded an error is thrown.
Image.Image decode(string data)
Returns the first successfully decoded bitmap image.
If no preview was stored, or no preview could be decoded an error is thrown.
| Module Nettle |
Low level crypto functions used by the Crypto module. Unless you are doing something very special, you would want to use the Crypto module instead.
string crypt_md5(string password, string salt)
Does the crypt_md5 abrakadabra (MD5 + snakeoil). It is assumed that salt does not contain "$".
| CLASS Nettle.CipherInfo |
Represents information about a cipher algorithm, such as name, key size, and block size.
string name()
A human readable name for the algorithm.
string key_size()
The recommended key size for the cipher.
string block_size()
The block size of the cipher (1 for stream ciphers).
| CLASS Nettle.CipherState |
Base class for hashing contexts.
CipherState set_encrypt_key(string key, void|int force)
Initializes the object for encryption.
set_decrypt_key , crypt
CipherState set_decrypt_key(string key, void|int force)
Initializes the object for decryption.
set_encrypt_key , crypt
string make_key()
Generate a key by calling Crypto.Random.random_string and initialize this object for encryption with that key.
The generated key.
set_encrypt_key
string crypt(string data)
Encrypts or decrypts data, using the current key.
For block ciphers, data must be an integral number of blocks.
The encrypted or decrypted data.
string key_size()
The actual key size for this cipher.
| CLASS Nettle.AES_Info |
Internal mixin class, intended to be multiply inherited together with CipherInfo.
| CLASS Nettle.AES_State |
State for AES encyption
| CLASS Nettle.ARCFOUR_Info |
Internal mixin class, intended to be multiply inherited together with CipherInfo.
| CLASS Nettle.ARCFOUR_State |
State for ARCFOUR encyption
| CLASS Nettle.BLOWFISH_Info |
Internal mixin class, intended to be multiply inherited together with CipherInfo.
| CLASS Nettle.BLOWFISH_State |
State for Blowfish encyption
| CLASS Nettle.CAST128_Info |
Internal mixin class, intended to be multiply inherited together with CipherInfo.
| CLASS Nettle.CAST128_State |
State for CAST128 encyption
| CLASS Nettle.DES_Info |
Internal mixin class, intended to be multiply inherited together with CipherInfo.
string fix_parity(string key)
Sets the last bit in every byte in key to reflect the parity. If a seven byte key is used, it will be expanded into eight bytes. If a key longer than eight characters is used, it will be truncated to eight characters.
| CLASS Nettle.DES_State |
State for DES encyption
| CLASS Nettle.DES3_Info |
Internal mixin class, intended to be multiply inherited together with CipherInfo.
string fix_parity(string key)
Sets the last bit in every byte in key to reflect the parity. If a 21 byte key is used, it will be expanded into 24 bytes. If a key longer than 24 characters is used, it will be truncated to 24 characters.
| CLASS Nettle.DES3_State |
State for DES3 encyption
| CLASS Nettle.Serpent_Info |
Internal mixin class, intended to be multiply inherited together with CipherInfo.
| CLASS Nettle.Serpent_State |
State for Serpent encyption
| CLASS Nettle.Twofish_Info |
Internal mixin class, intended to be multiply inherited together with CipherInfo.
| CLASS Nettle.Twofish_State |
State for Twofish encyption
| CLASS Nettle.IDEA_Info |
Internal mixin class, intended to be multiply inherited together with CipherInfo.
| CLASS Nettle.IDEA_State |
State for IDEA encyption
| CLASS Nettle.HashInfo |
Represents information about a hash algorithm, such as name, digest size, and internal block size.
string name()
Returns a human readable name for the algorithm.
string digest_size()
Returns the size of a hash digests.
string block_size()
Returns the internal block size of the hash algorithm.
string hash(string data)
Works as a (faster) shortcut for
obj->update(data)->digest().
HashState()->update() and HashState()->digest() .
string hash(Stdio.File file, void|int bytes)
Works as a (faster) shortcut for
obj->update(Stdio.read_file(file))->digest().
The number of bytes of the file object file that should be hashed. Negative numbers are ignored and the whole file is hashed.
Stdio.File , HashState()->update() and HashState()->digest() .
| CLASS Nettle.HashState |
Base class for hashing contexts.
HashState update(string data)
Hashes more data.
string digest(int|void length)
Generates a digests, and resets the hashing contents.
If the length argument is provided, the digest is truncated to the given length.
The digest.
| CLASS Nettle.MD5_Info |
Internal mixin class, intended to be multiply inherited together with HashInfo.
| CLASS Nettle.MD5_State |
State for MD5 hashing.
| CLASS Nettle.MD4_Info |
Internal mixin class, intended to be multiply inherited together with HashInfo.
| CLASS Nettle.MD4_State |
State for MD4 hashing.
| CLASS Nettle.MD2_Info |
Internal mixin class, intended to be multiply inherited together with HashInfo.
| CLASS Nettle.MD2_State |
State for MD2 hashing.
| CLASS Nettle.SHA1_Info |
Internal mixin class, intended to be multiply inherited together with HashInfo.
| CLASS Nettle.SHA1_State |
State for SHA1 hashing.
| CLASS Nettle.SHA256_Info |
Internal mixin class, intended to be multiply inherited together with HashInfo.
| CLASS Nettle.SHA256_State |
State for SHA256 hashing.
| CLASS Nettle.Yarrow |
Yarrow is a family of pseudo-randomness generators, designed for cryptographic use, by John Kelsey, Bruce Schneier and Niels Ferguson. Yarrow-160 is described in a paper at http://www.counterpane.com/yarrow.html, and it uses SHA1 and triple-DES, and has a 160-bit internal state. Nettle implements Yarrow-256, which is similar, but uses SHA256 and AES to get an internal state of 256 bits.
void Nettle.Yarrow(void|int sources)
The number of entropy sources that will feed entropy to the random number generator is given as an argument to Yarrow during instantiation.
update
Yarrow seed(string data)
The random generator needs to be seeded before it can be used. The seed must be at least 32 characters long. The seed could be stored from a previous run by inserting the value returned from get_seed .
Returns the called object.
min_seed_size , get_seed , is_seeded
int(0..) min_seed_size()
Returns the minimal number of characters that the seed needs to properly seed the random number generator.
seed
string get_seed()
Returns part of the internal state so that it can be saved for later seeding.
seed
int(0..1) is_seeded()
Returns 1 if the random generator is seeded and ready to generator output. 0 otherwise.
seed
void force_reseed()
By calling this function entropy is moved from the slow pool to the fast pool. Read more about Yarrow before using this.
int(0..1) update(string data, int source, int entropy)
Inject additional entropy into the random number generator.
create
int(0..) needed_sources()
The number of sources that must reach the threshold before a slow reseed will happen.
string random_string(int length)
Returns a pseudo-random string of the requested length .
| Module Shuffler |
constant Shuffler.INITIAL
constant Shuffler.RUNNING
constant Shuffler.PAUSED
constant Shuffler.DONE
constant Shuffler.WRITE_ERROR
constant Shuffler.READ_ERROR
constant Shuffler.USER_ABORT
| CLASS Shuffler.Throttler |
This is an interface that all Throttler s must implement. It's not an actual class in this module.
void request(Shuffle shuffle, int amount, function(int:void) callback)
This function is called when the Shuffle wants to send some data to a client.
When data can be sent, the callback function should be called with the amount of data that can be sent as the argument.
void give_back(Shuffle shuffle, int amount)
This function will be called by the Shuffle object to report that some data assigned to it by this throttler was unusued, and can be given to another Shuffle object instead.
| CLASS Shuffler.Shuffle |
This class contains the state for one ongoing data shuffling operation. To create a Shuffle instance, use the Shuffler()->shuffle method.
Shuffler Shuffler.Shuffle.shuffler
The Shuffler that owns this Shuffle object
Throttler Shuffler.Shuffle.throttler
The Throttler that is associated with this Shuffle object, if any.
void set_throttler(Throttler t)
Calling this function overrides the Shuffler global throttler.
int sent_data()
Returns the amount of data that has been sent so far.
int state()
Returns the current state of the shuffler. This is one of the following: INITIAL , RUNNING , PAUSED , DONE , WRITE_ERROR , READ_ERROR and USER_ABORT
void set_done_callback(function(Shuffle:void) cb)
Sets the done callback. This function will be called when all sources have been processed, or if an error occurs.
void set_request_arg(mixed arg)
Sets the extra argument sent to Throttler()->request() and Throttler()->give_back .
void send_more_callback(int amount)
void write_callback(mixed|void x)
void Shuffler.Shuffle(object fd, object shuffler, mixed throttler, mixed backend)
void start()
Start sending data from the sources.
void pause()
Temporarily pause all data transmission
void stop()
Stop all data transmission, and then call the done callback
void add_source(mixed source, int|void start, int|void length)
Add a new source to the list of data sources. The data from the sources will be sent in order.
If start and length are not specified, the whole source will be sent, if start but not length is specified, the whole source, excluding the first start bytes will be sent.
Currently supported sources
An ordinary 8-bit wide pike string.
An initialized instance of the System.Memory class.
Stdio.File instance pointing to a normal file.
Stdio.File instance pointing to a stream of some kind (network socket, named pipe, stdin etc).
Stdio.File lookalike with read callback support (set_read_callback and set_close_callback).
| CLASS Shuffler.Shuffler |
A data shuffler. An instance of this class handles a list of Shuffle objects. Each Shuffle object can send data from one or more sources to a destination in the background.
void set_backend(Pike.Backend b)
Set the backend that will be used by all Shuffle objects created from this shuffler.
void set_throttler(Throttler t)
Set the throttler that will be used in all Shuffle objects created from this shuffler, unless overridden in the Shuffle objects.
void pause()
Pause all Shuffle objects associated with this Shuffler
void start()
Unpause all Shuffle objects associated with this Shuffler
Shuffle shuffle(Stdio.File destination)
Create a new Shuffle object.
| Module GSSAPI |
This is pike glue for GSS-API ver 2 as specified in RFC 2743.
GSS-API is used to authenticate users and servers, and optionally also to encrypt communication between them. The API is generic and can be used without any knowledge of the actual implementation of these security services, which is typically provided by the operating system.
The most common implementation at the time of writing is Kerberos, which means that the main benefit of this API is to allow clients and servers to authenticate each other using Kerberos, thereby making single sign-on possible in a Kerberized environment.
All functions in this module that wraps GSS-API routines might throw GSSAPI.Error , and by default they do for all such errors. Only in some special cases do they return when a GSS-API error has happened, and that is noted in the documentation.
constant GSSAPI.int
Bitfield mask for the routine error part of major status codes like GSSAPI.Error.major_status . After applying this mask, the status values may be compared to any of the routine error constants.
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
Constants for routine errors in major status codes like GSSAPI.Error.major_status . See RFC 2743 section 1.2.1.1. Note that major status codes have to be masked with GSSAPI.ERROR_MASK before comparison with these.
Brief descriptions of the flags:
Channel binding mismatch.
Unsupported mechanism requested.
Invalid name provided.
Name of unsupported type provided.
Invalid input status selector.
Token had invalid integrity check.
Specified security context expired.
Expired credentials detected.
Defective credential detected.
Defective token detected.
Failure, unspecified at GSS-API level. GSSAPI.Error.minor_status should provide further details.
No valid security context specified.
No valid credentials provided.
Unsupported QOP value.
Operation unauthorized.
Operation unavailable.
Duplicate credential element requested.
Name contains multi-mechanism elements.
constant GSSAPI.int
Bitfield mask for the informatory part of major status codes like GSSAPI.Error.major_status .
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
Bitfield flags for informatory codes in major status codes like GSSAPI.Error.major_status . See RFC 2743 section 1.2.1.1. Any combination of these might optionally be combined with one routine error constant to form a major status code.
Brief descriptions of the flags:
Continuation call to routine required.
Duplicate per-message token detected.
Timed-out per-message token detected.
Reordered (early) per-message token detected.
Skipped predecessor token(s) detected.
array(string) major_status_messages(int major_status)
Given a major status code like GSSAPI.Error.major_status (or more commonly GSSAPI.Context.last_major_status in this case), returns an array containing messages for all the status values in it. The returned string(s) presumably don't end with linefeeds.
This wraps GSS_Display_status according to RFC 2743 section 2.4.1.
array(string) minor_status_messages(int minor_status, void|string mech)
Given a mechanism-specific minor status code like GSSAPI.Error.minor_status , returns an array containing messages for all the status values in it. The returned string(s) presumably don't end with linefeeds.
This wraps GSS_Display_status according to RFC 2743 section 2.4.1.
The mechanism-specific minor status.
The mechanism that produced the status code. If this is zero or left out, a system default mechanism is used.
constant GSSAPI.string
constant GSSAPI.string
constant GSSAPI.string
constant GSSAPI.string
constant GSSAPI.string
constant GSSAPI.string
constant GSSAPI.string
OIDs on dotted-decimal form for the GSS-API mechanism-independent name types, and some selected mechanism-specific ones:
Name type for a service associated with a host computer. The syntax is service@hostname where the @hostname part may be omitted for the local host. See RFC 2743 section 4.1.
Name type for a named user on a local system. The syntax is username. See RFC 2743 section 4.2.
Name type for a numeric user identifier corresponding to a user on a local system. The string representing a name of this type should contain a locally-significant user ID, represented in host byte order. See RFC 2743 section 4.3.
Name type for a string of digits representing the numeric user identifier of a user on a local system. This name type is similar to the Machine UID Form, except that the buffer contains a string representing the user ID. See RFC 2743 section 4.4.
Name type to identify anonymous names. See RFC 2743 section 4.5.
Name type for the Mechanism-Independent Exported Name Object type, which is the type of the names returned by GSSAPI.Name.export . See RFC 2743 section 4.7.
Name type for a Kerberos principal. See RFC 1964 section 2.1.1.
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
Flags for indicating how a GSSAPI.Cred object may be used:
The credential can only be used to initiate security contexts (i.e. using GSSAPI.InitContext ).
The credential can only be used to accept security contexts (i.e. using GSSAPI.AcceptContext ).
The credential may be used both to initiate or accept security contexts.
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
constant GSSAPI.int
Bitfield flags returned by e.g. GSSAPI.Context.services to denote various services that are available in the context.
Brief descriptions of the flags:
Delegation. See RFC 2743 section 1.2.9.
Mutual authentication (actually, acceptor authentication). See RFC 2743 sections 1.1.1.3 and 1.2.5.
Per-message replay detection. See RFC 2743 section 1.2.3.
Per-message sequencing. See RFC 2743 section 1.2.3.
Per-message confidentiality. See RFC 2743 section 1.2.2.
Per-message integrity. See RFC 2743 section 1.2.2.
Anonymous authentication. See RFC 2743 section 1.2.5.
Might be set before the context establishment has finished, to denote that per-message protection already is available. See RFC 2743 section 1.2.7. Is always set in GSSAPI.Context and derived classes when the context is established.
The context can be transferred between processes using GSSAPI.Context.export and GSSAPI.Context.import . See RFC 2743 section 1.2.10.
string describe_services(int services)
Returns a string that compactly describes the given services , which is taken as a bitfield of GSSAPI.*_FLAG flags.
The returned string contains capitalized names for the flags
reminiscent of the GSSAPI.*_FLAG constants, separated by
"|".
multiset(string) indicate_mechs()
Returns the OIDs for the available mechanism in the GSS-API implementation. The OIDs are returned on dotted-decimal form.
This wraps GSS_Indicate_mechs according to RFC 2743 section 2.4.2.
multiset(string) names_for_mech(string mech)
Returns the OIDs for the name types that the given mech supports. Both mech and the returned OID strings are on dotted-decimal form.
This wraps GSS_Inquire_names_for_mech according to RFC 2743 section 2.4.12.
| CLASS GSSAPI.Error |
Error object used for GSS-API errors.
inherit Error.Generic : Error.Generic
constant GSSAPI.Error.is_gssapi_error
constant GSSAPI.Error.error_type
Object recognition constants.
int GSSAPI.Error.major_status
The major status code. This is a bitwise OR of one routine error code and zero or more supplementary error info bits.
See RFC 2743 section 1.2.1.1 and RFC 2744 section 3.9.1. Note that the calling errors mentioned in RFC 2744 are never thrown.
major_status_messages
int GSSAPI.Error.minor_status
The minor status code specific for the mechanism.
minor_status_messages , minor_status_mech
void GSSAPI.Error(void|int major, void|int minor, void|string mech, void|string message, void|array backtrace)
Initial value for major_status .
Initial value for minor_status .
Object identifier on dotted-decimal form for the mechanism that minor applies to.
Error message. This is prepended to the message generated from
major_status and/or minor_status . ": " is inserted
in between.
Backtrace. The current backtrace for the calling function is used if left out.
array(string) major_status_messages()
Returns an array containing messages for all the status values in major_status . See GSSAPI.major_status_messages for further details.
array(string) minor_status_messages()
Returns an array containing messages for all the status values in minor_status . See GSSAPI.minor_status_messages for further details.
string minor_status_mech()
Returns the OID for the mechanism that is used to interpret the minor status, or zero if no mechanism has been set. It is returned on dotted-decimal form.
| CLASS GSSAPI.MissingServicesError |
Error object used when one or more required services are missing in a GSSAPI.Context object.
inherit Error.Generic : Error.Generic
constant GSSAPI.MissingServicesError.is_gssapi_missing_services_error
constant GSSAPI.MissingServicesError.error_type
Object recognition constants.
int GSSAPI.MissingServicesError.services
Bitfield of GSSAPI.*_FLAG flags for the missing services that caused the error.
GSSAPI.describe_services
void GSSAPI.MissingServicesError(void|int missing_services)
Initial value for services .
| CLASS GSSAPI.Name |
An object of this class contains a name on the internal form which is required by the GSS-API functions. See RFC 2743, section 1.1.5.
void GSSAPI.Name(string name, void|string name_type)
This wraps GSS_Import_name according to RFC 2743 section 2.4.5.
A name on string form (a contiguous string name in GSS-API parlance).
The OID on dotted-decimal form for the type of the name in name . If left out, name is parsed according to a mechanism-specific default printable syntax.
If name is the result of export or a similar function then name_type should be GSSAPI.NT_EXPORT_NAME .
string display_name()
string display_name_type()
display_name returns a representation of the name for display purposes, and display_name_type returns an OID on dotted-decimal form for the type of that name.
If no type was given to create then display_name_type might return zero.
This wraps GSS_Display_name according to RFC 2743 section 2.4.4.
The GSSAPI.NT_* constants.
Name canonicalize(string mech)
Returns a GSSAPI.Name containing the canonical mechanism name (MN) of this name. The mechanism is given as a dotted-decimal OID in mech .
This wraps GSS_Canonicalize_name according to RFC 2743 section 2.4.14.
This function might block on network connections to remote authentication servers.
string export(void|string mech)
Returns the name on the exported format. If mech isn't given then the name has to be a mechanism name (MN). If mech is given then the name is canonicalized according to that mechanism before being exported (see canonicalize ).
This wraps GSS_Export_name according to RFC 2743 section 2.4.15.
This function might block on network connections to remote authentication servers if mech is specified.
int `==(mixed other)
Returns true if other is a GSSAPI.Name which contains a name that refers to the same identity as this one.
This wraps GSS_Compare_name according to RFC 2743 section 2.4.3.
If either GSSAPI.Name object is uninitialized or contains an anonymous identity then they are considered different, unless it is the very same GSSAPI.Name object (that is an inherent pike behavior).
An error is thrown if the names are incomparable, or if either of them are ill-formed.
int __hash()
Tries to export the name (see export ) and if that succeeds returns a hash made from the exported name string. Otherwise a normal hash based on this object is returned.
This means that mechanism names (MNs) can be used as indices in mappings without getting duplicate entries for the same identity.
multiset(string) mechs()
Returns the OIDs for the mechanisms that might be able to process this name. The returned OID strings are on dotted-decimal form.
This wraps GSS_Inquire_mechs_for_name according to RFC 2743 section 2.4.13.
Some older GSS-API v2 implementations lack this funcion.
| CLASS GSSAPI.Cred |
Objects of this class hold one or more credentials that the current process can use to assert identities; see RFC 2743 section 1.1.1.
If a Cred object is destructed, GSS_Release_cred (RFC 2743, section 2.1.2) is called. The RFC doesn't preclude that that function might do blocking network I/O, which due to pike's object management might occur essentially anytime in any thread if the object isn't explicitly destructed. To avoid that, it's recommended to call release in credential objects that are no longer used.
void acquire(Name|string name, int cred_usage, void|multiset(string) desired_mechs, void|int(0..) desired_time)
Acquire initial credentials for this object. It is an error if it already has some credentials.
This wraps GSS_Acquire_cred according to RFC 2743 section 2.1.1.
The name of the identity for which credentials should be acquired. It is up to the GSS-API implementation to check whether the running process is authorized to act on behalf of this identity.
This can be either a GSSAPI.Name object or a string. In the latter case, the string is converted to a GSS-API name according to a mechanism-specific default printable syntax, i.e. just like if it would be given as the sole argument to GSSAPI.Name.create .
If this is zero then credentials for the default principal (if any) are retrieved.
Specifies how the credential will be used. One of GSSAPI.INITIATE , GSSAPI.ACCEPT or GSSAPI.BOTH .
The mechanisms that the credentials should cover, as a multiset containing their OIDs on dotted-decimal form. If zero or left out then a default set provided by the GSS-API implementation is used.
It is an error to pass an empty multiset.
Number of seconds the credentials should remain valid. The GSS-API implementation may return credentials that are valid both longer and shorter than this. Zero or left out means use the maximum permitted time.
This function might block on network connections to remote authentication servers.
void add(Name|string name, int cred_usage, string desired_mech, void|int(0..)|array(int(0..)) desired_time)
Adds another credential element to this object. If this object has no credentials already then it will get the default credentials in addition to this specified one.
This wraps GSS_Add_cred according to RFC 2743 section 2.1.4.
The name of the identity for which a credential should be acquired. It is up to the GSS-API implementation to check whether the running process has sufficient privileges to act on behalf of this identity.
This can be either a GSSAPI.Name object or a string. In the latter case, the string is converted to a GSS-API name according to a mechanism-specific default printable syntax, i.e. just like if it would be given as the sole argument to GSSAPI.Name.create .
If this is zero then a credential for the default principal (if any) are retrieved.
Specifies how the credential will be used. One of GSSAPI.INITIATE , GSSAPI.ACCEPT or GSSAPI.BOTH .
The mechanism that the credential should cover, as an OID on dotted-decimal form.
Number of seconds the credential should remain valid. The GSS-API implementation may return a credential that is valid both longer and shorter than this. Zero or left out means use the maximum permitted time.
This can also be an array containing two elements. In that case the first element applies to the credential when it is used to initiate contexts, and the second element applies to use for acceptor contexts.
This function might block on network connections to remote authentication servers.
GSSAPI.Name name(void|string mech)
int cred_usage(void|string mech)
multiset(string) mechs()
int(0..)|Int.inf lifetime()
int(0..)|Int.inf init_lifetime(string mech)
int(0..)|Int.inf accept_lifetime(string mech)
Functions to query various properties about the credentials.
These wrap GSS_Inquire_cred according to RFC 2743 section 2.1.3 if mech is not given, and GSS_Inquire_cred_by_mech according to section 2.1.5 otherwise.
If this is given then the credential for that specific mechanism is queried. mech contains the OID of the mechanism on dotted-decimal form.
Some of the query functions can only be used for a specific mechanism, in which case mech is required. Some can only be used on the credentials in general, and the mech argument is not applicable. Some can be used both ways, and then mech is optional.
name (void|string mech) Returns the name of the identity that the credential(s) assert. If mech is given then the returned name is a Mechanism Name (MN).
The returned GSSAPI.Name object is always a newly created one, even though it typically compares as equal with the ones given to acquire or add .
cred_usage (void|string mech) Returns how the credential(s) may be used, one of GSSAPI.INITIATE , GSSAPI.ACCEPT or GSSAPI.BOTH .
If mech is not given then the returned usage value reflects the union of the capabilities in all credentials.
mechs() Returns the set of mechanisms supported by the credential. The returned value is a multiset of strings with OIDs on dotted-decimal form.
lifetime() Returns the shortest validity lifetime left in any of the mechanisms that are part of the credentials, for either initiator or acceptor use.
Returns zero if some part of the credentials has expired.
Returns Int.inf if there is no time limit (in older pikes without Int.inf a large positive integer is returned instead).
init_lifetime (string mech) Returns the validity lifetime left for initiator use.
Returns zero if the credential has expired for this use or if its usage is GSSAPI.ACCEPT .
Returns Int.inf if there is no time limit (in older pikes without Int.inf a large positive integer is returned instead).
accept_lifetime (string mech) Returns the validity lifetime left for acceptor use.
Returns zero if the credential has expired for this use or if its usage is GSSAPI.INITIATE .
Returns Int.inf if there is no time limit (in older pikes without Int.inf a large positive integer is returned instead).
RFC 2743 doesn't preclude that these functions might block on network connections to remote authentication servers.
void release()
Frees the resources for the credential.
This wraps GSS_Release_cred according to RFC 2743 section 2.1.2.
This function might block on network connections to remote authentication servers.
| CLASS GSSAPI.Context |
Class representing a security context; see RFC 2743 section 1.1.3. The user usually instantiates one of the two inheriting classes GSSAPI.InitContext or GSSAPI.AcceptContext , based on whether the context should act as initiator or acceptor for the connection. This class is instantiated directly for imported contexts.
If a Context object for a partly or completely established context is destructed, GSS_Delete_sec_context (RFC 2743, section 2.2.3) is called. That function might do blocking network I/O, which due to pike's object management might occur essentially anytime in any thread if the object isn't explicitly destructed. To avoid that, it's strongly recommended to call delete in contexts that are no longer used.
void GSSAPI.Context(string interprocess_token, void|int required_services)
Creates a context by importing an inter-process token.
This wraps GSS_Import_sec_context according to RFC 2743 section 2.2.9.
The inter-process token which has been created by export or some other GSS_Export_sec_context wrapper.
Bitfield of GSSAPI.*_FLAG flags specifying all services that must be provided in the context. If the context fail to provide any of them then it is closed and a GSSAPI.MissingServicesError is thrown.
GSSAPI.PROT_READY_FLAG is ignored in this parameter. The fact that a user calls a per-message function indicates that this service is required at that point, and a GSSAPI.MissingServicesError is thrown if it isn't.
It is not possible to retrieve delegated credentials from an imported context. That is a GSS-API limitation.
int required_services(void|int services)
Gets and optionally sets the set of services that must be provided in the context. The returned and given value is a bitfield of the GSSAPI.*_FLAG constants.
This is mainly useful to change the per-message service flags that verify_mic and unwrap use to decide whether a condition is an error or not.
New set of required services. If this is not given then the set is not changed.
If the context is established and services contain a service which isn't currently provided then the context is closed and a GSSAPI.MissingServicesError is thrown immediately.
GSSAPI.PROT_READY_FLAG is ignored in this parameter.
Returns the current set of required services (after setting them to services , if provided).
GSSAPI.describe_services
int is_established()
int services()
int locally_initiated()
Name source_name()
Name target_name()
int(0..) lifetime()
string mech()
Functions to query various properties about the context.
These wrap GSS_Inquire_context according to RFC 2743 section 2.2.6.
Returns nonzero as soon as the context has been established. That means no further rounds through GSSAPI.InitContext.init or GSSAPI.AcceptContext.accept , that the remote peer is authenticated as required, and that the set of available services is complete (see services ).
Returns a bitfield of GSSAPI.*_FLAG flags for the services that the context (currently) provides. This field is complete only when the context establishment has finished, i.e. when is_established returns nonzero.
See also GSSAPI.describe_services .
Returns nonzero if the context is an initiator, zero if it is an acceptor. (This is mainly useful in imported contexts.)
Returns the name of the context initiator. The name is always an MN. Returns an anonymous name if used on the acceptor side and the anonymous authentication service (c.f. GSSAPI.ANON_FLAG ) was used.
Returns the name of the context acceptor. If a name is returned then it is always an MN.
Zero is returned on the initiator side if the initiator didn't specify a target name and the acceptor did not authenticate itself (should never happen if mutual authentication (c.f. GSSAPI.MUTUAL_FLAG ) is a required service).
The returned object is not necessarily the same one as was passed to GSSAPI.InitContext.create , even though they are likely to compare as equal (they might not be equal if the passed name wasn't an MN).
Returns the validity lifetime left for the context. Returns zero if the context has expired, or Int.inf if there is no time limit (in older pikes without Int.inf a large positive integer is returned instead).
Returns the mechanism that provides the context. The returned value is its OID on dotted-decimal form.
These functions don't throw errors if the context is missing or not completely established, even though they might not be able to query the proper values then (GSS-API implementations are known to not be completely reliable in handling these queries for partly established contexts). The functions instead return zero.
int last_major_status()
int last_minor_status()
Returns the major and minor status codes from the last operation that called a GSS-API routine, with the exception of those that wrap GSS_Inquire_context.
int last_qop()
Returns the quality of protection provided by the last call to verify_mic or unwrap .
int last_confidential()
Returns nonzero if the last call to wrap or unwrap provided confidentiality for the message, i.e. if wrap encrypted it or if unwrap decrypted it. Zero is returned otherwise.
void process_token(string remote_token)
Passes the given remote_token to the mechanism.
This wraps GSS_Process_context_token according to RFC 2743 section 2.2.4.
This is used for tokens that are received outside the handshaking between GSS_Init_sec_context (GSSAPI.InitContext.init ) and GSS_Accept_sec_context (GSSAPI.AcceptContext.accept ).
An example is when GSSAPI.InitContext.init returns a final token and flags the context as established, but the acceptor context detects an error and sends a failure token back. That token is processed using this function since GSSAPI.InitContext.init doesn't handle any more tokens by then.
This function might change context state.
This function might block on network connections to remote authentication servers. However, if the remote token is the result of GSS_Delete_sec_context on the remote side then it will not block.
string export()
Exports this context so that it can be imported in another process, providing the inter-process context transfer service is available (c.f. GSSAPI.TRANS_FLAG ).
This wraps GSS_Export_sec_context according to RFC 2743 section 2.2.8.
The returned string is intended to be fed to GSSAPI.Context.create (or some other GSS_Import_sec_context wrapper) in the receiving process.
This operation frees the context in this object.
string get_mic(string message, void|int qop)
Calculates and returns a MIC (message integrity checksum) for the given message that allows the receiver to verify its origin and integrity through verify_mic or some other GSS_VerifyMIC wrapper.
This wraps GSS_GetMIC according to RFC 2743 section 2.3.1.
This function requires that the context is established, or that the early per-message protection service is available (c.f. GSSAPI.PROT_READY_FLAG . If not, a GSSAPI.MissingServicesError is thrown (but the context is not closed).
The message for which the MIC is to be calculated. It may be of zero length.
The quality of protection. This is a mechanism-specific value that lets the user direct how the underlying mechanism calculates the MIC. See RFC 2743, section 1.2.4.
Zero or left out means use the default method.
int verify_mic(string message, string mic)
Verifies the origin and integrity of the given message using the given mic , which has been calculated by the sender using get_mic or some other GSS_GetMIC wrapper.
This wraps GSS_VerifyMIC according to RFC 2743 section 2.3.2.
This function requires that the context is established, or that the early per-message protection service is available (c.f. GSSAPI.PROT_READY_FLAG . If not, a GSSAPI.MissingServicesError is thrown (but the context is not closed).
Zero is returned if the verification fails with GSSAPI.DEFECTIVE_TOKEN or GSSAPI.BAD_MIC .
Otherwise the message origin and integrity checks out, but it might still be considered wrong depending on whether the replay detection or sequencing services are required (see required_services ):
If replay detection (c.f. GSSAPI.REPLAY_FLAG ) is required then zero is returned if the message is duplicated (GSSAPI.DUPLICATE_TOKEN ) or old (GSSAPI.OLD_TOKEN ).
If sequencing (c.f. GSSAPI.SEQUENCE_FLAG ) is required then in addition to the replay detection conditions, zero is also returned if the message is out of sequence (GSSAPI.UNSEQ_TOKEN or GSSAPI.GAP_TOKEN ).
Otherwise nonzero is returned to indicate that the message is valid according to the currently required services.
Any GSS-API errors except GSSAPI.DEFECTIVE_TOKEN and GSSAPI.BAD_MIC are thrown.
This function sets the value returned by last_qop .
Regardless whether the message is considered valid or not by the return value, last_major_status may be called to check for routine errors or the informatory codes mentioned above.
int(0..) wrap_size_limit(int(0..) output_size, int encrypt, void|int qop)
Returns the maximum size of an input string to wrap that would produce no more than output_size bytes in the resulting output.
This wraps GSS_Wrap_size_limit according to RFC 2743 section 2.2.7.
with_confidentiality and qop are the same as in the call to wrap .
string wrap(string message, void|int encrypt, void|int qop)
Calculates a MIC (message integrity checksum) for the given message, and returns it together with the message, which is optionally encrypted. The returned value can be verified and (if applicable) decrypted by the receiver using unwrap or some other GSS_Unwrap wrapper.
This wraps GSS_Wrap according to RFC 2743 section 2.3.3.
This function requires that the context is established, or that the early per-message protection service is available (c.f. GSSAPI.PROT_READY_FLAG . If not, a GSSAPI.MissingServicesError is thrown (but the context is not closed).
The message to be wrapped. It may be of zero length.
Set to nonzero to request that the message is encrypted. Otherwise only a MIC is calculated and the returned value contains the unencrypted message.
If this is set and the confidentiality service (c.f. GSSAPI.CONF_FLAG ) is required then the returned value is always encrypted. Otherwise it might not be encrypted anyway, and a call to last_confidential will tell if it is or not.
The quality of protection. This is a mechanism-specific value that lets the user direct how the underlying mechanism calculates the MIC. See RFC 2743, section 1.2.4.
Zero or left out means use the default method.
This function sets the value returned by last_confidential .
wrap_size_limit
string unwrap(string message, void|int accept_encrypted_only)
Verifies the origin and integrity of the given message using the MIC included in it, and also decrypts the message if it was encrypted. The message has been calculated by the sender using wrap or some other GSS_Wrap wrapper.
This wraps GSS_Unwrap according to RFC 2743 section 2.3.4.
This function requires that the context is established, or that the early per-message protection service is available (c.f. GSSAPI.PROT_READY_FLAG . If not, a GSSAPI.MissingServicesError is thrown (but the context is not closed).
The message to be unwrapped.
If this is nonzero then it is an error if message isn't encrypted, and zero is returned in that case (the status returned by last_major_status will still indicate success, though).
Zero is returned if the verification fails with GSSAPI.DEFECTIVE_TOKEN or GSSAPI.BAD_MIC .
Zero is also returned if message isn't encrypted and accept_encrypted_only is set.
Otherwise the message is successfully decrypted (provided it was encrypted to begin with), and its origin and integrity checks out, but it might still be considered wrong depending on whether the replay detection or sequencing services are required (see required_services ):
If replay detection (c.f. GSSAPI.REPLAY_FLAG ) is required then zero is returned if the message is duplicated (GSSAPI.DUPLICATE_TOKEN ) or old (GSSAPI.OLD_TOKEN ).
If sequencing (c.f. GSSAPI.SEQUENCE_FLAG ) is required then in addition to the replay detection conditions, zero is also returned if the message is out of sequence (GSSAPI.UNSEQ_TOKEN or GSSAPI.GAP_TOKEN ).
Otherwise the unwrapped message is returned, which is valid according to the currently required services (note however that requiring the confidentiality service does not imply that an error is signalled whenever an unencrypted message is received - see instead accept_encrypted_only above).
Any GSS-API errors except GSSAPI.DEFECTIVE_TOKEN and GSSAPI.BAD_MIC are thrown.
This function sets the value returned by last_confidential and last_qop .
Even if the message is considered valid by the return value, last_major_status may be called to check for the informatory codes mentioned above.
void delete()
Frees the resources for the context, provided it is in use. Does nothing otherwise.
This wraps GSS_Delete_sec_context according to RFC 2743 section 2.2.3.
This function might block on network connections to remote authentication servers.
In compliance with recommendations in GSS-API v2, the optional output token is never used in the call to GSS_Delete_sec_context.
| CLASS GSSAPI.InitContext |
Variant of Context which is used on the initiator side.
inherit Context : Context
void GSSAPI.InitContext(void|Cred cred, void|Name|string target_name, void|string mech, void|int required_services, void|int desired_services, void|int(0..) desired_time)
Creates a context for initiator use. This function only accepts parameters to be used later during the init call. If there are semantic problems with them, such as if the credentials are stale or the mechanism isn't supported, then they will be signalled later by init .
Credentials for the identity this context claims. The credentials for the default principal (if any) is used if zero or left out.
The name of the target.
This can be either a GSSAPI.Name object or a string. In the latter case, the string is converted to a GSS-API name according to a mechanism-specific default printable syntax, i.e. just like if it would be given as the sole argument to GSSAPI.Name.create .
Some mechanisms support unnamed targets (as allowed in GSS-API v2, update 1) and in such cases this may be zero or left out.
The mechanism to use. It is given as an OID on dotted-decimal form. The GSS-API implementation chooses this using system settings if it's zero or left out, which is the recommended way.
Bitfield of GSSAPI.*_FLAG flags specifying all services that must be provided in the context. If the context fail to provide any of them then it is closed and a GSSAPI.MissingServicesError is thrown.
GSSAPI.PROT_READY_FLAG is ignored in this parameter. The fact that a user calls a per-message function indicates that this service is required at that point, and a GSSAPI.MissingServicesError is thrown if it isn't.
Bitfield of GSSAPI.*_FLAG flags specifying the context services that are wanted but not required. I.e. errors won't be thrown if any of these aren't provided. The services specified in required_services are implicit, so they need not be repeated here.
GSSAPI.PROT_READY_FLAG is ignored in this parameter.
The desired context validity time in seconds. Zero or left out means use the default.
Channel bindings (RFC 2743, section 1.1.6) are not yet implemented since that feature appear to not be in much active use, and its format is not completely specified (RFC 2744, section 3.11).
string init(void|string remote_token)
Initiates a security context to send to a remote peer.
This wraps GSS_Init_sec_context according to RFC 2743 section 2.2.1.
The underlying mechanism might require several tokens to be passed back and forth to establish the context. If is_established returns zero after a call to this function then the caller must wait for a token from the remote peer to feed as remote_token in another call to this function.
A token from the remote peer, as returned by a call to GSSAPI.AcceptContext.accept (or some other GSS_Accept_sec_context wrapper) in it. This is zero or left out on the initial call, but used later if the remote peer sends back tokens to process as part of the context establishment.
If a string is returned then it must be passed to the remote peer which will feed it to GSSAPI.AcceptContext.accept or some other GSS_Accept_sec_context wrapper. An empty string is never returned.
Zero is returned if there is no token to send to the remote peer. Note that is_established might still return zero in that case, meaning more remote tokens are necessary.
This function might block on network connections to remote authentication servers.
| CLASS GSSAPI.AcceptContext |
Variant of Context which is used on the acceptor side.
inherit Context : Context
void GSSAPI.AcceptContext(void|Cred cred, void|int required_services)
Creates a context for acceptor use. This function only accepts parameters to be used later during the accept call. If there are semantic problems with them, such as if the credentials are stale, then they will be signalled later by accept .
Credentials for the identity this context claims. The credentials for the default principal (if any) is used if zero or left out.
Bitfield of GSSAPI.*_FLAG flags specifying all services that must be provided in the context. If the context fail to provide any of them then it is closed and a GSSAPI.MissingServicesError is thrown.
GSSAPI.PROT_READY_FLAG is ignored in this parameter. The fact that a user calls a per-message function indicates that this service is required at that point, and a GSSAPI.MissingServicesError is thrown if it isn't.
Channel bindings (RFC 2743, section 1.1.6) are not yet implemented since that feature appear to not be in much active use, and its format is not completely specified (RFC 2744, section 3.11).
string accept(string remote_token)
Accepts a remotely initiated security context.
This wraps GSS_Accept_sec_context according to RFC 2743 section 2.2.2.
The underlying mechanism might require several tokens to be passed back and forth to establish the context. If is_established returns zero after a call to this function then the caller must wait for a token from the remote peer to feed as remote_token in another call to this function.
A token from the remote peer, as returned by a call to GSSAPI.InitContext.init or some other GSS_Init_sec_context wrapper.
If a string is returned then it must be passed to the remote peer which will feed it to GSSAPI.InitContext.init or some other GSS_Init_sec_context wrapper. An empty string is never returned.
Zero is returned if there is no token to send to the remote peer. Note that is_established might still return zero in that case, meaning more remote tokens are necessary.
This function might block on network connections to remote authentication servers.
Cred delegated_cred()
Returns the delegated credentials from the initiator if the delegation (c.f. GSSAPI.DELEG_FLAG ) service is in use.
| Module Unicode |
array(string) split_words(string input)
Splits the input string into an array of words, on the boundaries between the different kinds of word characters as defined by is_wordchar . The result is an array of words, with the non-word characters between them thrown away.
array(string) split_words_and_normalize(string input)
A less wasteful equivalent of
split_words (normalize (input , "NFKD")).
string normalize(string data, string method)
Normalize the given unicode string according to the specified method.
The methods are:
NFC, NFD, NFKC and NFKD.
The methods are described in detail in the UAX #15 document, which can currently be found at http://www.unicode.org/unicode/reports/tr15/tr15-21.html
A short description:
C and D specifies whether to decompose (D) complex characters to their parts, or compose (C) single characters to complex ones.
K specifies whether or not do a canonical or compatibility conversion. When K is present, compatibility transformations are performed as well as the canonical transformations.
In the following text, 'X' denotes the single character 'X', even if there is more than one character inside the quotation marks. The reson is that it's somewhat hard to describe unicode in iso-8859-1.
The Unicode Standard defines two equivalences between characters: canonical equivalence and compatibility equivalence. Canonical equivalence is a basic equivalency between characters or sequences of characters.
'Å' and 'A' '° (combining ring above)' are canonically equivalent.
For round-trip compatibility with existing standards, Unicode has encoded many entities that are really variants of existing nominal characters. The visual representations of these character are typically a subset of the possible visual representations of the nominal character. These are given compatibility decompositions in the standard. Because the characters are visually distinguished, replacing a character by a compatibility equivalent may lose formatting information unless supplemented by markup or styling.
Examples of compatibility equivalences:
Font variants (thin, italic, extra wide characters etc)
Circled and squared characters
super/subscript ('²' -> '2')
Fractions ('½' -> '1/2')
Other composed characters ('fi' -> 'f' 'i', 'kg' -> 'k' 'g')
int is_wordchar(int c)
Returns whether a unicode character c is a word, part of a word or not.
|
constant Unicode.version
Contains the version of the current Unicode database as a string,
e.g. "5.0.0".
| Module Gdbm |
| CLASS Gdbm.gdbm |
void Gdbm.gdbm(void|string file, void|string mode)
Without arguments, this function does nothing. With one argument it opens the given file as a gdbm database, if this fails for some reason, an error will be generated. If a second argument is present, it specifies how to open the database using one or more of the follow flags in a string:
|
The fast mode prevents the database from syncronizing each change in the database immediately. This is dangerous because the database can be left in an unusable state if Pike is terminated abnormally.
The default mode is "rwc".
The gdbm manual states that it is important that the database is closed properly. Unfortunately this will not be the case if Pike calls exit() or returns from main(). You should therefore make sure you call close or destruct your gdbm objects when exiting your program. This will probably be done automatically in the future.
string fetch(string key)
string `[](string key)
Return the data associated with the key 'key' in the database. If there was no such key in the database, zero is returned.
int(0..1) delete(string key)
Remove a key from the database. Returns 1 if successful, otherwise 0, e.g. when the item is not present or the database is read only.
string firstkey()
Return the first key in the database, this can be any key in the database.
string nextkey(string key)
This returns the key in database that follows the key 'key' key. This is of course used to iterate over all keys in the database.
// Write the contents of the database for(key=gdbm->firstkey(); k; k=gdbm->nextkey(k)) write(k+":"+gdbm->fetch(k)+"\n");
string `[]=(string key, string data)
Associate the contents of 'data' with the key 'key'. If the key 'key' already exists in the database the data for that key will be replaced. If it does not exist it will be added. An error will be generated if the database was not open for writing.
gdbm[key] = data;
Returns data on success.
store()
int store(string key, string data)
Associate the contents of 'data' with the key 'key'. If the key 'key' already exists in the database the data for that key will be replaced. If it does not exist it will be added. An error will be generated if the database was not open for writing.
gdbm->store(key, data);
Returns 1 on success.
Note that the returned value differs from that of `[]=() .
`[]=()
int reorganize()
Deletions and insertions into the database can cause fragmentation which will make the database bigger. This routine reorganizes the contents to get rid of fragmentation. Note however that this function can take a LOT of time to run.
void sync()
When opening the database with the 'f' flag writings to the database can be cached in memory for a long time. Calling sync will write all such caches to disk and not return until everything is stored on the disk.
void close()
Closes the database.
| Module Gz |
The Gz module contains functions to compress and uncompress strings using the same algorithm as the program gzip. Compressing can be done in streaming mode or all at once.
The Gz module consists of two classes; Gz.deflate and Gz.inflate. Gz.deflate is used to pack data and Gz.inflate is used to unpack data. (Think "inflatable boat")
Note that this module is only available if the gzip library was available when Pike was compiled.
Note that although these functions use the same algorithm as gzip, they do not use the exact same format, so you cannot directly unzip gzipped files with these routines. Support for this will be added in the future.
int crc32(string data, void|int start_value)
This function calculates the standard ISO3309 Cyclic Redundancy Check.
inherit "___Gz"
| CLASS Gz.deflate |
Gz_deflate is a builtin program written in C. It interfaces the packing routines in the libz library.
This program is only available if libz was available and found when Pike was compiled.
Gz.inflate()
void Gz.deflate(int(0..9)|void level, int|void strategy, int(8..15) window_size)
If given, level should be a number from 0 to 9 indicating the packing / CPU ratio. Zero means no packing, 2-3 is considered 'fast', 6 is default and higher is considered 'slow' but gives better packing.
This function can also be used to re-initialize a Gz.deflate object so it can be re-used.
If the argument is negative, no headers will be emitted. This is needed to produce ZIP-files, as an example. The negative value is then negated, and handled as a positive value.
strategy , if given, should be one of DEFAULT_STRATEGY, FILTERED or HUFFMAN_ONLY.
window_size defines the size of the LZ77 window from 256 bytes to 32768 bytes, expressed as 2^x.
string compress(string data, void|int(0..1) raw, void|int(0..9) level, void|int strategy, void|int(8..15) window_size)
string deflate(string data, int|void flush)
This function performs gzip style compression on a string data and returns the packed data. Streaming can be done by calling this function several times and concatenating the returned data.
The optional argument flush should be one of the following:
|
Gz.inflate->inflate()
| CLASS Gz.inflate |
Gz_deflate is a builtin program written in C. It interfaces the unpacking routines in the libz library.
This program is only available if libz was available and found when Pike was compiled.
deflate
void Gz.inflate(int|void window_size)
The window_size value is passed down to inflateInit2 in zlib.
If the argument is negative, no header checks are done, and no verification of the data will be done either. This is needed for uncompressing ZIP-files, as an example. The negative value is then negated, and handled as a positive value.
Positive arguments set the maximum dictionary size to an exponent of 2, such that 8 (the minimum) will cause the window size to be 256, and 15 (the maximum, and default value) will cause it to be 32Kb. Setting this to anything except 15 is rather pointless in Pike.
It can be used to limit the amount of memory that is used to uncompress files, but 32Kb is not all that much in the great scheme of things.
To decompress files compressed with level 9 compression, a 32Kb window size is needed. level 1 compression only requires a 256 byte window.
string uncompress(string data, void|int(0..1) raw)
string inflate(string data)
This function performs gzip style decompression. It can inflate a whole file at once or in blocks.
// whole file write(Gz_inflate()->inflate(stdin->read(0x7fffffff));
// streaming (blocks) function inflate=Gz_inflate()->inflate; while(string s=stdin->read(8192)) write(inflate(s));
Gz.deflate->deflate()
string end_of_stream()
This function returns 0 if the end of stream marker has not yet been encountered, or a string (possibly empty) containg any extra data received following the end of stream marker if the marker has been encountered. If the extra data is not needed, the result of this function can be treated as a logical value.
| CLASS Gz._file |
Low-level implementation of read/write support for GZip files
int open(string|int|Stdio.Stream file, void|string mode)
Opens a file for I/O.
The filename or an open filedescriptor or Stream for the GZip file to use.
Mode for the fileoperations. Defaults to read only.
If the object already has been opened, it will first be closed.
void Gz._file(void|string|Stdio.Stream gzFile, void|string mode)
Opens a gzip file for reading.
int close()
closes the file
1 if successful
int|string read(int len)
Reads len (uncompressed) bytes from the file. If read is unsuccessful, 0 is returned.
int write(string data)
Writes the data to the file.
the number of bytes written to the file.
int seek(int pos, void|int type)
Seeks within the file.
Position relative to the searchtype.
SEEK_SET = set current position in file to pos SEEK_CUR = new position is current+pos SEEK_END is not supported.
New position or negative number if seek failed.
int tell()
the current position within the file.
int(0..1) eof()
1 if EOF has been reached.
int setparams(int level, int strategy)
Sets the encoding level and strategy
Level of the compression. 0 is the least compression, 9 is max. 8 is default.
Set strategy for encoding to one of the following: DEFAULT_STRATEGY FILTERED HUFFMAN_ONLY
| CLASS Gz.File |
Allows the user to open a Gzip archive and read and write it's contents in an uncompressed form, emulating the Stdio.File interface.
An important limitation on this class is that it may only be used for reading or writing, not both at the same time. Please also note that if you want to reopen a file for reading after a write, you must close the file before calling open or strange effects might be the result.
inherit _file : _file
void Gz.File(void|string|int|Stdio.Stream file, void|string mode)
Filename or filedescriptor of the gzip file to open, or an already open Stream.
mode for the file. Defaults to "rb".
open Stdio.File
int open(string|int|Stdio.Stream file, void|string mode)
Filename or filedescriptor of the gzip file to open, or an already open Stream.
mode for the file. Defaults to "rb". May be one of the following:
read mode
write mode
append mode
For the wb and ab mode, additional parameters may be specified. Please se zlib manual for more info.
non-zero if successful.
int|string read(void|int length)
Reads data from the file. If no argument is given, the whole file is read.
| Module Regexp |
inherit "___Regexp"
SimpleRegexp `()(void|string regexp)
Convenience/compatibility method to get a SimpleRegexp object.
int(0..1) match(string regexp, string data)
Calls Regexp.PCRE.Plain.match in a temporary regexp object. Faster to type but slower to run...
array split(string regexp, string data)
Calls Regexp.PCRE.Plain.split in a temporary regexp object. Faster to type but slower to run...
array split2(string regexp, string data)
Calls Regexp.PCRE.Plain.split2 in a temporary regexp object. Faster to type but slower to run...
string replace(string regexp, string data, string|function(string:string) transform)
Calls Regexp.PCRE.Plain.replace in a temporary regexp object. Faster to type but slower to run...
| CLASS Regexp.SimpleRegexp |
This class implements the interface to a simple regexp engine with the following capabilities:
|
Note that \ can be used to quote these characters in which case they match themselves, nothing else. Also note that when quoting these something in Pike you need two \ because Pike also uses this character for quoting.
inherit _SimpleRegexp : _SimpleRegexp
string replace(string in, string|function(string:string) transform)
mixed _encode()
mixed _decode(string s)
Regexp objects can be encoded and decoded.
encode_value , decode_value
void Regexp.SimpleRegexp(string re)
When create is called, the current regexp bound to this object is cleared. If a string is sent to create(), this string will be compiled to an internal representation of the regexp and bound to this object for laters calls to e.g. match or split . Calling create() without an argument can be used to free up a little memory after the regexp has been used.
int match(string str)
Returns 1 if str matches the regexp bound to the regexp object. Zero otherwise.
array(string) match(array(string) strs)
Returns an array containing strings in strs that match the regexp bound to the regexp object.
The current implementation doesn't support searching in strings containing the NUL character or any wide character.
split
array(string) split(string s)
Works as match , but returns an array of the strings that matched the subregexps. Subregexps are those contained in "( )" in the regexp. Subregexps that were not matched will contain zero. If the total regexp didn't match, zero is returned.
You can currently only have 39 subregexps.
The current implementation doesn't support searching in strings containing the NUL character or any wide character.
match
| Module Regexp.PCRE |
array(string) split_subject(string subject, array(int) previous_result)
Convenience function that splits a subject string on the result from _pcre->exec()
equal to map(previous_result/2, lambda(array v) { return subject[v[0]..v[1]-1]; })
constant Regexp.PCRE.buildconfig_UTF8
(from the pcreapi man-page) "The output is an integer that is set to one if UTF-8 support is available; otherwise it is set to zero." This constant is calculated when the module is initiated by using pcre_config(3).
constant Regexp.PCRE.buildconfig_NEWLINE
(from the pcreapi man-page) "The output is an integer that is set to the value of the code that is used for the newline character. It is either linefeed (10) or carriage return (13), and should normally be the standard character for your operating system." This constant is calculated when the module is initiated by using pcre_config(3).
constant Regexp.PCRE.buildconfig_LINK_SIZE
(from the pcreapi man-page) "The output is an integer that contains the number of bytes used for internal linkage in compiled regular expressions. The value is 2, 3, or 4. Larger values allow larger regular expressions to be compiled, at the expense of slower match- ing. The default value of 2 is sufficient for all but the most massive patterns, since it allows the compiled pattern to be up to 64K in size." This constant is calculated when the module is initiated by using pcre_config(3).
constant Regexp.PCRE.buildconfig_POSIX_MALLOC_THRESHOLD
(from the pcreapi man-page) "The output is an integer that contains the threshold above which the POSIX interface uses malloc() for output vectors. Further details are given in the pcreposix documentation." This constant is calculated when the module is initiated by using pcre_config(3).
constant Regexp.PCRE.buildconfig_MATCH_LIMIT
(from the pcreapi man-page) "The output is an integer that gives the default limit for the number of internal matching function calls in a pcre_exec() execution. Further details are given with pcre_exec() below." This constant is calculated when the module is initiated by using pcre_config(3).
| CLASS Regexp.PCRE._pcre |
void Regexp.PCRE._pcre(string pattern, void|int options, void|object table)
The option bits are:
|
object study()
(from the pcreapi man-page) "When a pattern is going to be used several times, it is worth spending more time analyzing it in order to speed up the time taken for match- ing."
string _sprintf(int c, mapping flags)
mapping info()
Returns additional information about a compiled pattern. Only available if PCRE was compiled with Fullinfo.
|
int|array exec(string subject, void|int startoffset)
match a regexp; will return an array of 2*n integers where n is the number of hits; returns an int upon failure
Error codes:
|
int get_stringnumber(string stringname)
returns the number of a named subpattern
| Module Regexp.PCRE.OPTION |
contains all option constants
constant Regexp.PCRE.OPTION.ANCHORED
(from the pcreapi manpage) If this bit is set, the pattern is forced to be "anchored", that is, it is constrained to match only at the first matching point in the string which is being searched (the "subject string"). This effect can also be achieved by appropriate constructs in the pattern itself, which is the only way to do it in Perl.
constant Regexp.PCRE.OPTION.CASELESS
(from the pcreapi manpage) If this bit is set, letters in the pattern match both upper and lower case letters. It is equivalent to Perl's /i option, and it can be changed within a pattern by a (?i) option setting.
constant Regexp.PCRE.OPTION.DOLLAR_ENDONLY
(from the pcreapi manpage) If this bit is set, a dollar metacharacter in the pattern matches only at the end of the subject string. Without this option, a dollar also matches immediately before the final character if it is a newline (but not before any other newlines). The PCRE_DOLLAR_ENDONLY option is ignored if PCRE_MULTILINE is set. There is no equivalent to this option in Perl, and no way to set it within a pattern.
constant Regexp.PCRE.OPTION.DOTALL
(from the pcreapi manpage) If this bit is set, a dot metacharater in the pattern matches all characters, including newlines. Without it, newlines are excluded. This option is equivalent to Perl's /s option, and it can be changed within a pattern by a (?s) option setting. A negative class such as [^a] always matches a newline character, independent of the setting of this option.
constant Regexp.PCRE.OPTION.EXTENDED
(from the pcreapi manpage) If this bit is set, whitespace data characters in the pattern are totally ignored except when escaped or inside a character class. Whitespace does not include the VT character (code 11). In addition, characters between an unescaped # outside a character class and the next newline character, inclusive, are also ignored. This is equivalent to Perl's /x option, and it can be changed within a pattern by a (?x) option setting.
This option makes it possible to include comments inside complicated patterns. Note, however, that this applies only to data characters. Whitespace characters may never appear within special character sequences in a pattern, for example within the sequence (?( which introduces a conditional subpattern.
constant Regexp.PCRE.OPTION.EXTRA
(from the pcreapi manpage) This option was invented in order to turn on additional functionality of PCRE that is incompatible with Perl, but it is currently of very little use. When set, any backslash in a pattern that is followed by a letter that has no special meaning causes an error, thus reserving these combinations for future expansion. By default, as in Perl, a backslash followed by a letter with no special meaning is treated as a literal. There are at present no other features controlled by this option. It can also be set by a (?X) option setting within a pattern.
constant Regexp.PCRE.OPTION.MULTILINE
(from the pcreapi manpage) By default, PCRE treats the subject string as consisting of a single "line" of characters (even if it actually contains several newlines). The "start of line" metacharacter (^) matches only at the start of the string, while the "end of line" metacharacter ($) matches only at the end of the string, or before a terminating newline (unless PCRE_DOL- LAR_ENDONLY is set). This is the same as Perl.
When PCRE_MULTILINE it is set, the "start of line" and "end of line" constructs match immediately following or immediately before any new- line in the subject string, respectively, as well as at the very start and end. This is equivalent to Perl's /m option, and it can be changed within a pattern by a (?m) option setting. If there are no "\n" charac- ters in a subject string, or no occurrences of ^ or $ in a pattern, setting PCRE_MULTILINE has no effect.
constant Regexp.PCRE.OPTION.NO_AUTO_CAPTURE
(from the pcreapi manpage) If this option is set, it disables the use of numbered capturing paren- theses in the pattern. Any opening parenthesis that is not followed by ? behaves as if it were followed by ?: but named parentheses can still be used for capturing (and they acquire numbers in the usual way). There is no equivalent of this option in Perl.
constant Regexp.PCRE.OPTION.UNGREEDY
(from the pcreapi manpage) This option inverts the "greediness" of the quantifiers so that they are not greedy by default, but become greedy if followed by "?". It is not compatible with Perl. It can also be set by a (?U) option setting within the pattern.
constant Regexp.PCRE.OPTION.UTF8
(from the pcreapi manpage) This option causes PCRE to regard both the pattern and the subject as strings of UTF-8 characters instead of single-byte character strings. However, it is available only if PCRE has been built to include UTF-8 support. If not, the use of this option provokes an error. Details of how this option changes the behaviour of PCRE are given in the section on UTF-8 support in the main pcre page.
| Module Regexp.PCRE.ERROR |
constant Regexp.PCRE.ERROR.NOMATCH
constant Regexp.PCRE.ERROR.NULL
constant Regexp.PCRE.ERROR.BADOPTION
constant Regexp.PCRE.ERROR.BADMAGIC
constant Regexp.PCRE.ERROR.UNKNOWN_NODE
constant Regexp.PCRE.ERROR.NOMEMORY
constant Regexp.PCRE.ERROR.NOSUBSTRING
constant Regexp.PCRE.ERROR.MATCHLIMIT
constant Regexp.PCRE.ERROR.CALLOUT
Documented in exec .
| Module Regexp.PCRE._Regexp_PCRE |
inherit "____Regexp_PCRE"
GOOD `()(string pattern, void|int options, void|object table)
Convenience function to create a suitable PCRE Regexp object; will create a StudiedWidestring from the arguments.
That means the result will be able to handle widestrings, and will produce fast matchings by studying the pattern, but the widestring wrapping will on the other hand add overhead.
If you need a faster regexp and doesn't use widestring, create a Regexp.PCRE.Studied instead.
Widestring support will not be used if the linked libpcre lacks UTF8 support. This can be tested with checking that the Regexp.PCRE.Widestring class exist.
| CLASS Regexp.PCRE._Regexp_PCRE.Plain |
The main regexp class. Will provide anything needed for matching regexps.
There are subclasses that adds wrappers for widestrings, and to optimize the regexp pattern.
inherit _pcre : _pcre
array(string)|int(0..0) split2(string subject, void|int startoffset)
Matches a subject against the pattern, returns an array where the first element are the whole match, and the subsequent are the matching subpatterns. Returns 0 if there was no match.
example: > Regexp.PCRE.Plain("i\(.*\) is \(.*\)u")->split2("pike is fun"); Result: ({ "ike is fu", "ke", "f" })
array(string)|int(0..0) split(string subject, void|int startoffset)
Matches a subject against the pattern, compatible with the old split method: returns an array of the subpatterns, or if there are no subpattern but still a match, ({0}). Returns 0 if there was no match.
example: > Regexp.PCRE.Plain("i\(.*\) is \(.*\)u")->split("pike is fun"); (1) Result: ({ "ke", "f" }) > Regexp.PCRE.Plain("is fun")->split("pike is fun"); (4) Result: ({ 0 })
int(0..1) match(string subject, void|int startoffset)
returns true (1) if a match is found, false otherwise
example: > Regexp.PCRE.Plain("is fun")->match("pike is fun"); Result: 1 > Regexp.PCRE.Plain("is fun")->match("pike isn't fun"); Result: 0
string replace(string subject, string|function(string:string) with)
replace all occurances of a pattern in a subject; callbacks and replacements will be from the first occurance, not from the last as in Regexp.Builtin.replace.
example: > Regexp.PCRE("b[^-]*m")->replace("abam-boom-fooabadoom","gurka"); Result: "agurka-gurka-fooagurka" > Regexp.PCRE("b[^-]*m")->replace("abam-boom-fooabadoom", lambda(string s) { werror("%O\n",s); return "gurka"; }); "bam" "boom" "badoom" Result: "agurka-gurka-fooagurka"
string replace1(string subject, string|function(string:string) with)
replace one (first) occurance of a pattern in a subject
example: > Regexp.PCRE("b[^-]*m")->replace1("abam-boom-fooabadoom","gurka"); Result: "agurka-boom-fooabadoom"
this_program matchall(string subject, function(array(string)|void:mixed|void) callback)
Will give a callback for each match in a subject. Called arguments will be matching patterns and subpatterns in an array and as second argument the exec result array.
returns called object
example: > Regexp.PCRE("b(a*)([^-\1234]*)(\1234*)m") ->matchall("abam-boom-fooabado\1234m", lambda(mixed s) { werror("%O\n",s); return "gurka"; }); ({ /* 4 elements */ "bam", "a", "", "" }) ({ /* 4 elements */ "boom", "", "oo", "" }) ({ /* 4 elements */ "bado\1234m", "a", "do", "\1234" }) Result: Regexp.PCRE.StudiedWidestring("b(a*)([^-Ê\234]*)(Ê\234*)m")
string replace_positional(string subject, string subst)
replaces matches in a string, with support for backreferences (matched groups)
the string to be tested against the regular expression
string to be inserted in place of each match. backreferences can be inserted into the string to be substituted using the syntax %[n]s where n is the nth matching string group, and 0 (zero) is the full match.
example: > Regexp.PCRE.Plain("my name is ([a-zA-Z]+)")->replace_positional("allow me to introduce myself: my name is john", "%[0]s is my name"); (1) Result: "allow me to introduce myself: john is my name"
| CLASS Regexp.PCRE._Regexp_PCRE.Studied |
Same as Plain, but will be studied to match faster; useful if you're doing many matches on the same pattern
inherit Plain : Plain
| CLASS Regexp.PCRE._Regexp_PCRE.Widestring |
Wrapper class around Plain, that will allow widestring patterns and subjects.
Widestring support and this class will not be implemented if the linked libpcre lacks UTF8 support.
inherit Plain : Plain
array(int)|int exec(string subject, void|int startoffset)
The exec function is wrapped to give the correct indexes for the widestring.
| CLASS Regexp.PCRE._Regexp_PCRE.StudiedWidestring |
Same as Widestring, but will be studied to match faster; useful if you're doing many matches on the same pattern
inherit Widestring : Widestring
| Module Msql |
This is an interface to the mSQL database server. This module may or may not be availible on your Pike, depending whether the appropriate include and library files (msql.h and libmsql.a respectively) could be found at compile-time. Note that you do not need to have a mSQL server running on your host to use this module: you can connect to the database over a TCP/IP socket
Please notice that unless you wish to specifically connect to a mSQL server, you'd better use the Sql.Sql program instead. Using Sql.Sql ensures that your Pike applications will run with any supported SQL server without changing a single line of code.
Also notice that some functions may be mSQL/2.0-specific, and thus missing on hosts running mSQL/1.0.*
The mSQL C API has some extermal dependencies. They take the form of certain environment variables which, if defined in the environment of the pike interpreter, influence the interface's behavior. Those are "MSQL_TCP_PORT" which forces the server to connect to a port other than the default, "MSQL_UNIX_PORT", same as above, only referring to the UNIX domain sockets. If you built your mSQL server with the default setttings, you shouldn't worry about these. The variable MINERVA_DEBUG can be used to debug the mSQL API (you shouldn't worry about this either). Refer to the mSQL documentation for further details.
Also note that THIS MODULE USES BLOCKING I/O to connect to the server. mSQL should be reasonably fast, but you might want to consider this particular aspect. It is thread-safe, and so it can be used in a multithread environment.
Although it seems that mSQL/2.0 has some support for server statistics, it's really VERY VERY primitive, so it won't be added for now.
Sql.Sql
constant Msql.version
Should you need to report a bug to the author, please submit along with the report the driver version number, as returned by this call.
| CLASS Msql.msql |
void shutdown()
This function shuts a SQL-server down.
void reload_acl()
This function forces a server to reload its ACLs.
This function is not part of the standard interface, so it is not availible through the Sql.Sql interface, but only through Sql.msql and Msql.msql programs.
create
void Msql.msql(void|string dbserver, void|string dbname, void|string username, void|string passwd)
With one argument, this function
tries to connect to the specified (use hostname or IP address) database
server. To connect to a server running on the local host via UNIX domain
sockets use "localhost". To connect to the local host via TCP/IP
sockets
you have to use the IP address "127.0.0.1".
With two arguments it also selects a database to use on the server.
With no arguments it tries to connect to the server on localhost, using
UNIX sockets.
You need to have a database selected before using the sql-object, otherwise you'll get exceptions when you try to query it. Also notice that this function can raise exceptions if the db server doesn't respond, if the database doesn't exist or is not accessible by you.
You don't need bothering about syncronizing the connection to the database: it is automatically closed (and the database is sync-ed) when the msql object is destroyed.
select_db
array list_dbs(void|string wild)
Returns an array containing the names of all databases availible on the system. Will throw an exception if there is no server connected. If an argument is specified, it will return only those databases whose name matches the given glob.
array list_tables(void|string wild)
Returns an array containing the names of all the tables in the currently selected database. Will throw an exception if we aren't connected to a database. If an argument is specified, it will return only those tables whose name matches the given glob.
void select_db(string dbname)
Before querying a database you have to select it. This can be accomplished in two ways: the first is calling the create function with two arguments, another is calling it with one or no argument and then calling select_db . You can also use this function to change the database you're querying, as long as it is on the same server you are connected to.
This function CAN raise exceptions in case something goes wrong (for example: unexistant database, insufficient permissions, whatever).
create , error
array(mapping(string:mixed)) query(string sqlquery)
This is all you need to query the database. It takes as argument an SQL query string (i.e.: "SELECT foo,bar FROM baz WHERE name like '%kinkie%'" or "INSERT INTO baz VALUES ('kinkie','made','this')") and returns a data structure containing the returned values. The structure is an array (one entry for each returned row) of mappings which have the column name as index and the column contents as data. So to access a result from the first example you would have to do "results[0]->foo".
A query which returns no data results in an empty array (and NOT in a 0). Also notice that when there is a column name clash (that is: when you join two or more tables which have columns with the same name), the clashing columns are renamed to <tablename>+"."+<column name>. To access those you'll have to use the indexing operator '[] (i.e.: results[0]["foo.bar"]).
Errors (both from the interface and the SQL server) are reported via exceptions, and you definitely want to catch them. Error messages are not particularly verbose, since they account only for errors inside the driver. To get server-related error messages, you have to use the error function.
Note that if the query is NOT a of SELECT type, but UPDATE or MODIFY, the returned value is an empty array. This is not an error. Errors are reported only via exceptions.
error
string server_info()
This function returns a string describing the server we are talking to. It has the form "servername/serverversion" (like the HTTP protocol description) and is most useful in conjunction with the generic SQL-server module.
string host_info()
This function returns a string describing what host are we talking to, and how (TCP/IP or UNIX sockets).
string error()
This function returns the textual description of the last server-related error. Returns 0 if no error has occurred yet. It is not cleared upon reading (can be invoked multiple times, will return the same result until a new error occurs).
query
void create_db(string dbname)
This function creates a new database with the given name (assuming we have enough permissions to do this).
drop_db
void drop_db(string dbname)
This function destroys a database and all the data it contains (assuming we have enough permissions to do so). USE WITH CAUTION!
create_db
mapping(string:mapping(string:mixed)) list_fields(string table, void|string glob)
Returns a mapping describing the fields of a table in the database. The returned value is a mapping, indexed on the column name, of mappings.The glob argument, if present, filters out the fields not matching the glob. These contain currently the fields:
|
The version of this function in the Msql.msql() program is not sql-interface compliant (this is the main reason why using that program directly is deprecated). Use Sql.Sql instead.
query
int affected_rows()
This function returns how many rows in the database were affected by our last SQL query.
This function is availible only if you're using mSQL version 2 or later. (That means: if the includes and library of version 2 of mSQL were availible when the module was compiled).
This function is not part of the standard interface, so it is not availible through the Sql.Sql interface, but only through Sql.msql and Msql.msql programs
array list_index(string tablename, string indexname)
This function returns an array describing the index structure for the given table and index name, as defined by the non-standard SQL query 'create index' (see the mSQL documentation for further informations). More than one index can be created for a table. There's currently NO way to have a listing of the indexes defined for a table (blame it on the mSQL API).
This function is availible if you're using mSQL version 2 or later.
This function is not part of the standard interface, so it is not availible through the Sql.Sql interface, but only through Sql.msql and Msql.msql programs.
| Module Yp |
This module is an interface to the Yellow Pages functions. Yp is also known as NIS (Network Information System) and is most commonly used to distribute passwords and similar information within a network.
inherit "___Yp"
string default_domain()
Returns the default yp-domain.
| CLASS Yp.Map |
Network Information Service aka YP map.
void Yp.Map(string map, string|void domain)
Create a new YP-map object.
map is the YP-map to bind to. This may be a nickname, such as passwd instead of just passwd.byname.
If domain is not specified, the default domain will be used.
If there is no YP server available for the domain, this function call will block until there is one. If no server appears in about ten minutes or so, an error will be returned. The timeout is not configurable.
string match(string key)
string `[](string key)
Search for the key key . If there is no key in the map, 0 (zero) will be returned, otherwise the string matching the key will be returned.
key must match exactly, no pattern matching of any kind is done.
mapping(string:string) all()
mapping(string:string) cast_to_mapping()
Returns the whole map as a mapping.
void map(function(string:void) fun)
Call a function for each entry in the map.
For each entry in the map, call the function fun .
The function will be called like
void fun(string key, string value).
string server()
Return the server that provides this map.
int order()
Return the order number for this map.
int _sizeof()
Return the number of entries in this map.
array(string) _indices()
Return the keys of the map.
array(string) _values()
Return the values of the map.
| CLASS Yp.Domain |
string server(string map)
Returns the hostname of the server serving the map map . map is the YP-map to search in. This must be the full map name. eg passwd.byname instead of just passwd.
void Yp.Domain(string|void domain)
void bind(string domain)
If domain is not specified , the default domain will be used. (As returned by Yp.default_domain() ).
If there is no YP server available for the domain, this function call will block until there is one. If no server appears in about ten minutes or so, an error will be returned. This timeout is not configurable.
Yp.default_domain()
mapping(string:string) all(string map)
Returns the whole map as a mapping.
map is the YP-map to search in. This must be the full map name, you have to use passwd.byname instead of just passwd.
void map(string map, function(string:void) fun)
For each entry in map , call the function specified by fun .
fun will get two arguments, the first being the key, and the second the value.
map is the YP-map to search in. This must be the full map name. eg passwd.byname instead of just passwd.
int order(string map)
Returns the 'order' number for the map map .
This is usually the number of seconds since Jan 1 1970 (see time() ). When the map is changed, this number will change as well.
map is the YP-map to search in. This must be the full map name. eg passwd.byname instead of just passwd.
string match(string map, string key)
Search for the key key in the Yp-map map .
If there is no key in the map, 0 (zero) will be returned, otherwise the string matching the key will be returned.
key must match exactly, no pattern matching of any kind is done.
| Module CommonLog |
The CommonLog module is used to parse the lines in a www server's logfile, which must be in "common log" format -- such as used by default for the access log by Roxen, Caudium, Apache et al.
int read(function(array(int|string):void) callback, Stdio.File|string logfile, void|int offset)
Reads the log file and calls the callback function for every parsed line. For lines that fails to be parsed the callback is not called not is any error thrown. The number of bytes read are returned.
The callbacks first argument is an array with the different parts of the log entry.
| ||||||||||||||||||||||||||||||||
The second callback argument is the current offset to the end of the current line.
The position in the file where the parser should begin.
| Module Gmp |
GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating point numbers. There is no practical limit to the precision except the ones implied by the available memory in the machine GMP runs on. http://www.swox.com/gmp/
Gmp.mpz fac(int x)
Returns the factorial of x (x !).
| CLASS Gmp.mpf |
GMP floating point number.
The mantissa of each float has a user-selectable precision, limited only by available memory. Each variable has its own precision, and that can be increased or decreased at any time.
The exponent of each float is a fixed precision, one machine word on most systems. In the current implementation the exponent is a count of limbs, so for example on a 32-bit system this means a range of roughly 2^-68719476768 to 2^68719476736, or on a 64-bit system this will be greater.
Each variable keeps a size for the mantissa data actually in use. This means that if a float is exactly represented in only a few bits then only those bits will be used in a calculation, even if the selected precision is high.
All calculations are performed to the precision of the destination variable. Each function is defined to calculate with "infinite precision" followed by a truncation to the destination precision, but of course the work done is only what's needed to determine a result under that definition.
The precision selected for a variable is a minimum value, GMP may increase it a little to facilitate efficient calculation. Currently this means rounding up to a whole limb, and then sometimes having a further partial limb, depending on the high limb of the mantissa. But applications shouldn't be concerned by such details.
The mantissa in stored in binary, as might be imagined from the fact precisions are expressed in bits. One consequence of this is that decimal fractions like 0.1 cannot be represented exactly. The same is true of plain IEEE double floats. This makes both highly unsuitable for calculations involving money or other values that should be exact decimal fractions. (Suitably scaled integers, or perhaps rationals, are better choices.)
mpf functions and variables have no special notion of infinity or not-a-number, and applications must take care not to overflow the exponent or results will be unpredictable. This might change in a future release.
Note that the mpf functions are not intended as a smooth extension to IEEE P754 arithmetic. In particular results obtained on one computer often differ from the results on a computer with a different word size.
void Gmp.mpf(void|int|string|float|object x, void|int(0..) precision)
void Gmp.mpf(string x, int(0..) precision, int(2..36) base)
int __hash()
int|object get_int()
float get_float()
Returns the value of the object as a float.
string get_string()
string _sprintf(int c, mapping flags)
int(0..1) _is_type(string arg)
The Gmp.mpf object will claim to be a "float".
Perhaps it should also return true for "object"?
mixed cast(string to)
Gmp.mpf `+(int|float|object ... a)
Gmp.mpf `+=(int|float|object ... a)
Gmp.mpf set_precision(int(0..) prec)
Sets the precision of the current object to be at least prec bits. The precision is limited to 128Kb. The current object will be returned.
int(0..) get_precision()
Returns the current precision, in bits.
Gmp.mpf `*(int|float|object ... a)
Gmp.mpf ``*(int|float|object ... a)
Gmp.mpf `*=(int|float|object ... a)
Gmp.mpf `-(int|float|object ... a)
Gmp.mpf ``-(int|float|object sv)
Gmp.mpf `/(int|float|object ... a)
Gmp.mpf ``/(int|float|object sv)
Gmp.mpf `~()
int(0..1) `>(mixed q)
int(0..1) `<(mixed q)
int(0..1) `>=(mixed q)
int(0..1) `<=(mixed q)
int(0..1) `==(mixed q)
int(0..1) `!=(mixed q)
int sgn()
int(0..1) `!()
| CLASS Gmp.bignum |
This program is used by the internal auto-bignum conversion. It can be used to explicitly type integers that are too big to be INT_TYPE. Best is however to not use this program unless you really know what you are doing.
Due to the auto-bignum conversion, all integers can be treated as
Gmp.mpz objects insofar as that they can be indexed with the
functions in the Gmp.mpz class. For instance, to calculate the
greatest common divisor between 51 and 85, you can
do 51->gcd(85). In other words, all the functions in
Gmp.mpz are also available here.
| CLASS Gmp.mpz |
Gmp.mpz implements very large integers. In fact, the only limitation on these integers is the available memory. The mpz object implements all the normal integer operations.
Note that the auto-bignum feature also makes these operations
available "in" normal integers. For instance, to calculate the
greatest common divisor between 51 and 85, you can
do 51->gcd(85).
void Gmp.mpz()
void Gmp.mpz(string|int|float|object value)
void Gmp.mpz(string value, int(2..36)|int(256..256) base)
Create and initialize a Gmp.mpz object.
Initial value. If no value is specified, the object will be initialized to zero.
Base the value is specified in. The default base is base 10. The base can be either a value in the range [2..36] (inclusive), in which case the numbers are taken from the ASCII range 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ (case-insensitive), or the value 256, in which case value is taken to be the binary representation in network byte order.
Leading zeroes in value are not significant. In particular leading NUL characters are not preserved in base 256 mode.
int cast_to_int()
int __hash()
float cast_to_float()
string cast_to_string()
string digits(void|int(2..36)|int(256..256) base)
Convert this mpz object to a string. If a base is given the number will be represented in that base. Valid bases are 2-36 and 256. The default base is 10.
cast_to_string
string _sprintf(int ind, mapping opt)
int(0..1) _is_type(string type)
int size(void|int base)
Return how long this mpz would be represented in the specified base . The default base is 2.
mixed cast(string type)
Cast this mpz object to another type. Allowed types are string, int and float.
cast_to_int , cast_to_float , cast_to_string
Gmp.mpz `+(int|float|Gmp.mpz ... x)
Gmp.mpz ``+(int|float|Gmp.mpz ... x)
Gmp.mpz `+=(int|float|Gmp.mpz ... x)
Gmp.mpz `*(int|float|Gmp.mpz ... x)
Gmp.mpz ``*(int|float|Gmp.mpz ... x)
Gmp.mpz `*=(int|float|Gmp.mpz ... x)
Gmp.mpz gcd(object|int|float|string ... arg)
Return the greatest common divisor between this mpz object and all the arguments.
Gmp.mpz `-(int|float|Gmp.mpz ... x)
Gmp.mpz ``-(int|float|Gmp.mpz ... x)
Gmp.mpz `/(int|float|Gmp.mpz ... x)
Gmp.mpz ``/(int|float|Gmp.mpz ... x)
Gmp.mpz `%(int|float|Gmp.mpz ... x)
Gmp.mpz ``%(int|float|Gmp.mpz ... x)
array(Gmp.mpz) gcdext(int|float|Gmp.mpz x)
Compute the greatest common divisor between this mpz object and
x . An array ({g,s,t}) is returned where g is
the greatest common divisor, and s and t are the
coefficients that satisfies
this * s + x * t = g
gcdext2 , gcd
array(Gmp.mpz) gcdext2(int|float|Gmp.mpz x)
Compute the greatest common divisor between this mpz object and
x . An array ({g,s}) is returned where g is the
greatest common divisor, and s is a coefficient that
satisfies
this * s + x * t = g
where t is some integer value.
gcdext , gcd
Gmp.mpz invert(int|float|Gmp.mpz x)
Return the inverse of this mpz value modulo x . The returned
value satisfies 0 <= result < x.
An error is thrown if no inverse exists.
Gmp.mpz fac()
Return the factorial of this mpz object.
Since factorials grow very quickly, only small integers are supported. An error is thrown if the value in this mpz object is too large.
Gmp.mpz bin(int k)
Return the binomial coefficient n over k , where
n is the value of this mpz object. Negative values of
n are supported using the identity
(-n)->bin(k) == (-1)->pow(k) * (n+k-1)->bin(k)
(See Knuth volume 1, section 1.2.6 part G.)
The k value can't be arbitrarily large. An error is thrown if it's too large.
Gmp.mpz `&(int|float|Gmp.mpz ... x)
Gmp.mpz `|(int|float|Gmp.mpz ... x)
Gmp.mpz `^(int|float|Gmp.mpz ... x)
Gmp.mpz `~()
int(0..1) `>(mixed with)
int(0..1) `<(mixed with)
int(0..1) `>=(mixed with)
int(0..1) `<=(mixed with)
int(0..1) `==(mixed with)
int(0..1) `!=(mixed with)
int(0..1) probably_prime_p()
Return 1 if this mpz object is a prime, and 0 most of the time if it is not.
int small_factor(void|int(1..) limit)
Gmp.mpz next_prime(void|int count, void|int limit)
int sgn()
Gmp.mpz sqrt()
Return the the truncated integer part of the square root of this mpz object.
array(Gmp.mpz) sqrtrem()
Gmp.mpz `<<(int|float|Gmp.mpz x)
Gmp.mpz `>>(int|float|Gmp.mpz x)
Gmp.mpz ``<<(int|float|Gmp.mpz x)
Gmp.mpz ``>>(int|float|Gmp.mpz x)
Gmp.mpz powm(int|string|float|Gmp.mpz exp, int|string|float|Gmp.mpz mod)
Return ( this->pow(exp ) ) % mod .
pow
Gmp.mpz pow(int|float|Gmp.mpz x)
Return this mpz object raised to x . The case when zero is raised to zero yields one.
powm
int(0..1) `!()
int popcount()
For values >= 0, returns the population count (the number of set bits). For negative values (who have an infinite number of leading ones in a binary representation), -1 is returned.
Gmp.mpz _random()
| CLASS Gmp.mpq |
Rational number stored in canonical form. The canonical from means that the denominator and the numerator have no common factors, and that the denominator is positive. Zero has the unique representation 0/1. All functions canonicalize their result.
void Gmp.mpq(void|string|int|float|Gmp.mpz|Gmp.mpq x)
void Gmp.mpq(int numerator, int denominator)
void Gmp.mpq(string x, int base)
int get_int()
int __hash()
float get_float()
string get_string()
string _sprintf(int c, mapping flags)
int(0..1) _is_type(string arg)
int|string|float|object cast(string s)
Gmp.mpq `+(int|float|object ... a)
Gmp.mpq ``+(int|float|object ... a)
Gmp.mpq `+=(int|float|object ... a)
Gmp.mpq `*(int|float|object ... a)
Gmp.mpq ``*(int|float|object ... a)
Gmp.mpq `*=(int|float|object ... a)
Gmp.mpq `-(int|float|object ... a)
Gmp.mpq ``-(int|float|object sv)
Gmp.mpq `/(int|float|object ... a)
Gmp.mpq ``/(int|float|object sv)
Gmp.mpq `%(int|float|object ... a)
a%b = a - floor(a/b)*b
Gmp.mpq ``%(int|float|object a)
Gmp.mpq invert()
Gmp.mpq `~()
Defined as -1-x.
int(0..1) `>(mixed q)
int(0..1) `<(mixed q)
int(0..1) `>=(mixed q)
int(0..1) `<=(mixed q)
int(0..1) `==(mixed q)
int(0..1) `!=(mixed q)
int(-1..1) sgn()
int(0..1) `!(mixed q)
| Module DVB |
Implements Digital Video Broadcasting interface
Only Linux version is supported.
| CLASS DVB.dvb |
Main class.
void DVB.dvb(int card_number)
Create a DVB object.
The number of card equipment.
The number specifies which device will be opened. Ie. /dev/ost/demux0, /dev/ost/demux1 ... for DVB v0.9.4 or /dev/dvb/demux0, /dev/dvb/demux1 ... for versions 2.0+
mapping|int fe_status()
Return status of a DVB object's frondend device.
The resulting mapping contains the following fields:
|
mapping fe_info()
Return info of a frondend device.
The information heavily depends on driver. Many fields contain dumb values.
int tune(int(0..3) lnb, int freq, int(0..1)|string pol, int sr)
Tunes to apropriate transponder's parameters.
DiSeQc number of LNB.
Frequency divided by 1000.
Polarization. 0 or "v" for vertical type,
1 or "h" for horizontal one.
The service rate parameter.
mapping|int get_pids()
Returns mapping with info of currently tuned program's pids.
tune()
mapping analyze_pat()
Return mapping of all PMT.
sid:prognum
array(mapping)|int analyze_pmt(int sid, int prognum)
Parse PMT table.
analyze_pat()
DVB.Stream stream(int pid, int|function rcb, int ptype)
DVB.Stream stream(int pid, int|function rcb)
DVB.Stream stream(int pid)
Create a new stream reader object for PID.
PID of stream.
Callback function called whenever there is the data to read from stream. Only for nonblocking mode.
Type of payload data to read. By default, audio data is fetched.
Setting async callback doesn't set the object to nonblocking state.
DVB.Stream()->read()
| CLASS DVB.Stream |
Represents an elementary data stream (PES).
int destroy()
Purge a stream reader.
DVB.dvb()->stream() , read()
string|int read()
Read data from a stream. It reads up to read buffer size data.
Read buffer size is 4096 by default.
DVB.dvb()->stream() , close()
void close()
Closes an open stream.
read()
| CLASS DVB.Audio |
Object for controlling an audio subsystem on full featured cards.
void DVB.Audio(int card_number)
void DVB.Audio()
Create a Audio object.
The number of card equipment.
int mute(int mute)
int mute()
Mute or unmute audio device.
mapping status()
Returns mapping of current audio device status.
int mixer(int left, int right)
int mixer(int both)
Sets output level on DVB audio device.
| Module Pipe |
Single socket output.
Regular file output and (multiple, adding) socket output with no mmap input.
Multiple socket output without regular file output illegal.
| CLASS Pipe.pipe |
Concatenation pipe.
void input(object obj)
Add an input file to this pipe.
void write(string bytes)
Add an input string to this pipe.
void output(object obj, int|void start_pos)
Add an output file object.
void set_done_callback(void|function(mixed:mixed) done_cb, void|mixed id)
Set the callback function to be called when all the outputs have been sent.
void set_output_closed_callback(void|function(mixed:mixed) close_cb, void|mixed id)
Set the callback function to be called when one of the outputs has been closed from the other side.
void finish()
Terminate and reinitialize the pipe.
void start()
Start sending the input(s) to the output(s).
int bytes_sent()
Return the number of bytes sent.
string version()
Return the version of the module.
| Module Mysql |
This module enables access to the Mysql database from within Pike. Use Sql.Sql for general database access.
Mysql is available from http://www.mysql.com.
Mysql.mysql , Mysql.mysql_result , Sql.Sql
| CLASS Mysql.mysql_result |
Objects of this class contain the result from Mysql queries.
Mysql.mysql , Mysql.mysql->big_query()
void Mysql.mysql_result(Mysql.mysql connection)
Make a new Mysql.mysql_result object.
Mysql.mysql->big_query() , Mysql.mysql->list_dbs() , Mysql.mysql->list_tables() , Mysql.mysql->list_processes() , Mysql.mysql
int num_rows()
Number of rows in the result.
num_fields()
int num_fields()
Number of fields in the result.
num_rows()
void field_seek(int field_no)
Skip to specified field.
Places the field cursor at the specified position. This affects which field mysql_result->fetch_field() will return next.
Fields are numbered starting with 0.
This function is usually not enabled. To enable it SUPPORT_FIELD_SEEK must be defined when compiling the mysql-module.
fetch_field() , fetch_fields()
int(0..1) eof()
Sense end of result table.
Returns 1 when all rows have been read, and 0 (zero)
otherwise.
fetch_row()
int|mapping(string:mixed) fetch_field()
Return specification of the current field.
Returns a mapping with information about the current field, and
advances the field cursor one step. Returns 0 (zero) if
there are no more fields.
The mapping contains the same entries as those returned by
Mysql.mysql->list_fields() , except that the entry "default"
is missing.
This function is usually not enabled. To enable it SUPPORT_FIELD_SEEK must be defined when compiling the mysql-module.
fetch_fields() , field_seek() , Mysql.mysql->list_fields()
array(int|mapping(string:mixed)) fetch_fields()
Get specification of all remaining fields.
Returns an array with one mapping for every remaining field in the result table.
The returned data is similar to the data returned by
Mysql.mysql->list_fields() , except for that the entry
"default" is missing.
Resets the field cursor to 0 (zero).
This function always exists even when fetch_field() and field_seek() don't.
fetch_field() , field_seek() , Mysql.mysql->list_fields()
void seek(int rows)
Skip ahead rows rows.
Can only seek forward.
fetch_row()
int|array(string) fetch_row()
Fetch the next row from the result.
Returns an array with the contents of the next row in the result. Advances the row cursor to the next now.
Returns 0 (zero) at the end of the table.
seek()
| CLASS Mysql.mysql |
Interface to the Mysql database.
This class enables access to the Mysql database from within Pike.
Mysql is available from http://www.mysql.com.
Mysql.mysql_result , Sql.Sql
void Mysql.mysql()
void Mysql.mysql(string host)
void Mysql.mysql(string host, string database)
void Mysql.mysql(string host, string database, string user)
void Mysql.mysql(string host, string database, string user, string password)
void Mysql.mysql(string host, string database, string user, string password, mapping(string:string|int) options)
Connect to a Mysql database.
To access the Mysql database, you must first connect to it. This is done with this function.
If you give no argument, or give "" as host it will connect
with a UNIX-domain socket, which can be a big performance gain.
This optional mapping can contain zero or more of the following parameters:
|
Some options may not be implemented. Unimplemented options are silently ignored.
To use SSL-connections, set the SSL-parameters correctly. They correspond to the parameters given to the mysql-client with the same name so make sure that the mysql-client works with SSL and set these parameters to the same values and everything should work. If SSL-options are loaded from a config-file, one may set the connect_options to include CLIENT_SSL.
If Pike has been built with an old MySQL client lib then it
might not be possible to specify some charsets that the server
supports with the "mysql_charset_name" option. In such
cases it's possible that set_charset works better (provided
the server is 4.1 or newer).
string _sprintf(int type, void|mapping flags)
int affected_rows()
Returns the number of rows affected by the last query.
int insert_id()
Returns the id of the last INSERT query into a table with an AUTO INCREMENT field.
string error()
Returns a string describing the last error from the Mysql-server.
Returns 0 (zero) if there was no error.
void select_db(string database)
Select database.
The Mysql-server can hold several databases. You select which one you want to access with this function.
create() , create_db() , drop_db()
void create_db(string database)
Create a new database
This function creates a new database named database in the Mysql-server.
select_db() , drop_db()
void drop_db(string database)
Drop a database
This function drops the database named database from the Mysql-server.
create_db() , select_db()
void shutdown()
Shutdown the Mysql-server
This function shuts down a running Mysql-server.
reload()
void reload()
Reload security tables
This function causes the Mysql-server to reload its access tables.
shutdown()
string statistics()
Some Mysql-server statistics
This function returns some server statistics.
server_info() , host_info() , protocol_info()
string server_info()
Get the version number of the Mysql-server.
statistics() , host_info() , protocol_info()
string host_info()
Get information about the Mysql-server connection
statistics() , server_info() , protocol_info()
int protocol_info()
Give the Mysql protocol version
This function returns the version number of the protocol the Mysql-server uses.
statistics() , server_info() , host_info()
Mysql.mysql_result list_dbs()
Mysql.mysql_result list_dbs(string wild)
List databases
Returns a table containing the names of all databases in the Mysql-server. If the argument wild is specified, only those matching it will be returned.
list_tables() , list_fields() , list_processes() , Mysql.mysql_result
Mysql.mysql_result list_tables()
Mysql.mysql_result list_tables(string wild)
List tables in the current database
Returns a table containing the names of all tables in the current database. If the argument wild is given, only those matching it will be returned.
list_dbs() , list_fields() , list_processes() , Mysql.mysql_result
array(int|mapping(string:mixed)) list_fields(string table)
array(int|mapping(string:mixed)) list_fields(string table, string wild)
List all fields.
Returns an array of mappings with information about the fields in the table named table . If the argument wild is given, only those fields matching it will be returned
The mappings contain the following entries:
|
The type of the field can be any of:
"decimal", "char", "short", "long",
"float", "double", "null", "time",
"longlong", "int24", "tiny blob",
"medium blob",
"long blob", "var string", "string" or
"unknown".
The flags multiset can contain any of:
|
Michael Widenius recomends use of the following query instead: show fields in 'table' like "wild".
list_dbs() , list_tables() , list_processes() , Mysql.mysql_result.fetch_field()
Mysql.mysql_result list_processes()
List all processes in the Mysql-server
Returns a table containing the names of all processes in the Mysql-server.
list_dbs() , list_tables() , list_fields() , Mysql.mysql_result
int binary_data()
Inform if this version of Mysql.mysql supports binary data
This function returns non-zero if binary data can be reliably stored and retreived with this version of the mysql-module.
Usually, there is no problem storing binary data in mysql-tables,
but data containing '\0' (NUL) couldn't be fetched with old
versions (prior to 3.20.5) of the mysql-library.
| Module System |
This module embodies common operating system calls, making them available to the Pike programmer.
string|int|array(string) RegGetValue(int hkey, string key, string index)
Get a single value from the register.
One of the following:
|
Registry key.
Value name.
Returns the value stored at the specified location in the register if any. Throws errors on failure.
This function is only available on Win32 systems.
RegGetValues() , RegGetKeyNames()
array(string) RegGetKeyNames(int hkey, string key)
Get a list of value key names from the register.
One of the following:
|
A registry key.
Returns an array of value keys stored at the specified location if any. Throws errors on failure.
> RegGetKeyNames(HKEY_CURRENT_USER, "Keyboard Layout"); (1) Result: ({ "IMEtoggle", "Preload", "Substitutes", "Toggle" })
This function is only available on Win32 systems.
RegGetValue() , RegGetValues()
mapping(string:string|int|array(string)) RegGetValues(int hkey, string key)
Get multiple values from the register.
One of the following:
|
Registry key.
Returns a mapping with all the values stored at the specified location in the register if any. Throws errors on failure.
> RegGetValues(HKEY_CURRENT_USER, "Keyboard Layout\\Preload"); (5) Result: ([ "1":"0000041d" ])
This function is only available on Win32 systems.
RegGetValue() , RegGetKeyNames()
object LogonUser(string username, string|int(0..0) domain, string password, int|void logon_type, int|void logon_provider)
Logon a user.
User name of the user to login.
Domain to login on, or zero if local logon.
Password to login with.
One of the following values:
|
One of the following values:
|
Returns a login token object on success, and zero on failure.
This function is only available on some Win32 systems.
string|array(string|int) NetUserGetInfo(string username, string|int(0..0) server, int|void level)
Get information about a network user.
User name of the user to get information about.
Server the user exists on.
Information level. One of:
|
Returns an array on success. Throws errors on failure.
Document the return value.
This function is only available on some Win32 systems.
NetUserEnum() , NetGroupEnum() NetLocalGroupEnum() , NetUserGetGroups() , NetUserGetLocalGroups() , NetGroupGetUsers() , NetLocalGroupGetMembers() , NetGetDCName() , NetGetAnyDCName()
array(string|array(string|int)) NetUserEnum(string|int(0..0)|void server, int|void level, int|void filter)
Get information about network users.
Server the users exist on.
Information level. One of:
|
Returns an array on success. Throws errors on failure.
Document the return value.
This function is only available on some Win32 systems.
NetUserGetInfo() , NetGroupEnum() NetLocalGroupEnum() , NetUserGetGroups() , NetUserGetLocalGroups() , NetGroupGetUsers() , NetLocalGroupGetMembers() , NetGetDCName() , NetGetAnyDCName()
array(string|array(string|int)) NetGroupEnum(string|int(0..0)|void server, int|void level)
Get information about network groups.
Server the groups exist on.
Information level. One of:
|
Returns an array on success. Throws errors on failure.
Document the return value.
This function is only available on some Win32 systems.
NetUserGetInfo() , NetUserEnum() , NetLocalGroupEnum() , NetUserGetGroups() , NetUserGetLocalGroups() , NetGroupGetUsers() , NetLocalGroupGetMembers() , NetGetDCName() , NetGetAnyDCName()
array(array(string|int)) NetLocalGroupEnum(string|int(0..0)|void server, int|void level)
Get information about local network groups.
Server the groups exist on.
Information level. One of:
|
Returns an array on success. Throws errors on failure.
Document the return value.
This function is only available on some Win32 systems.
NetUserGetInfo() , NetUserEnum() , NetGroupEnum() , NetUserGetGroups() , NetUserGetLocalGroups() , NetGroupGetUsers() , NetLocalGroupGetMembers() , NetGetDCName() , NetGetAnyDCName()
array(array(string|int)) NetUserGetGroups(string|int(0..0) server, string user, int|void level)
Get information about group membership for a network user.
Server the groups exist on.
User to retrieve groups for.
Information level. One of:
|
Returns an array on success. Throws errors on failure.
Document the return value.
This function is only available on some Win32 systems.
NetUserGetInfo() , NetUserEnum() , NetGroupEnum() , NetLocalGroupEnum() , NetUserGetLocalGroups() , NetGroupGetUsers() , NetLocalGroupGetMembers() , NetGetDCName() , NetGetAnyDCName()
array(string) NetUserGetLocalGroups(string|int(0..0) server, string user, int|void level, int|void flags)
Get information about group membership for a local network user.
Server the groups exist on.
User to retrieve groups for.
Information level. One of:
|
Zero, of one of the following:
|
Returns an array on success. Throws errors on failure.
Document the return value.
This function is only available on some Win32 systems.
NetUserGetInfo() , NetUserEnum() , NetGroupEnum() , NetLocalGroupEnum() , NetUserGetGroups() , NetGroupGetUsers() , NetLocalGroupGetMembers() , NetGetDCName() , NetGetAnyDCName()
array(string|array(int|string)) NetGroupGetUsers(string|int(0..0) server, string group, int|void level)
Get information about group membership for a network group.
Server the groups exist on.
Group to retrieve members for.
Information level. One of:
|
Returns an array on success. Throws errors on failure.
Document the return value.
This function is only available on some Win32 systems.
NetUserGetInfo() , NetUserEnum() , NetGroupEnum() , NetLocalGroupEnum() , NetUserGetGroups() , NetUserGetLocalGroups() , NetLocalGroupGetMembers() , NetGetDCName() , NetGetAnyDCName()
array(string|array(int|string)) NetLocalGroupGetMembers(string|int(0..0) server, string group, int|void level)
Get information about group membership for a network group.
Server the groups exist on.
Group to retrieve members for.
Information level. One of:
|
Returns an array on success. Throws errors on failure.
Document the return value.
This function is only available on some Win32 systems.
NetUserGetInfo() , NetUserEnum() , NetGroupEnum() , NetLocalGroupEnum() , NetUserGetGroups() , NetUserGetLocalGroups() , NetGroupGetUsers() , NetGetDCName() , NetGetAnyDCName()
string NetGetDCName(string|int(0..0) server, string domain)
Get name of the domain controller from a server.
Server the domain exists on.
Domain to get the domain controller for.
Returns the name of the domain controller on success. Throws errors on failure.
This function is only available on some Win32 systems.
NetUserGetInfo() , NetUserEnum() , NetGroupEnum() , NetLocalGroupEnum() , NetUserGetGroups() , NetUserGetLocalGroups() , NetGroupGetUsers() , NetLocalGroupGetMembers() , NetGetAnyDCName()
string NetGetAnyDCName(string|int(0..0) server, string domain)
Get name of a domain controller from a server.
Server the domain exists on.
Domain to get a domain controller for.
Returns the name of a domain controller on success. Throws errors on failure.
This function is only available on some Win32 systems.
NetUserGetInfo() , NetUserEnum() , NetGroupEnum() , NetLocalGroupEnum() , NetUserGetGroups() , NetUserGetLocalGroups() , NetGroupGetUsers() , NetLocalGroupGetMembers() , NetGetDCName()
array(int|string) NetSessionEnum(string|int(0..0) server, string|int(0..0) client, string|int(0..0) user, int level)
Get session information.
One of
|
This function is only available on some Win32 systems.
array(mixed) NetWkstaUserEnum(string|int(0..0) server, int level)
One of
|
This function is only available on some Win32 systems.
string normalize_path(string path)
Normalize an existing Windows file system path.
The following transformations are currently done:
Forward slashes ('/') are converted to backward
slashes ('\').
Trailing slashes are removed, except a single slash after a
drive letter (e.g. "C:\" is returned instead of
"C:").
Extraneous empty extensions are removed.
Short filenames are expanded to their corresponding long variants.
Relative paths are expanded to absolute paths.
Current- and parent-directory path components ("."
and "..") are followed, similar to combine_path .
Case-information in directory and file names is restored.
Drive letters are returned in uppercase.
The host and share parts of UNC paths are returned in lowercase.
A normalized absolute path without trailing slashes.
Throws errors on failure, e.g. if the file or directory doesn't exist.
File fork information is currently not supported (invalid data).
In Pike 7.6 and earlier, this function didn't preserve a single slash after drive letters, and it didn't convert the host and share parts of an UNC path to lowercase.
combine_path() , combine_path_nt()
int GetFileAttributes(string filename)
Get the file attributes for the specified file.
This function is only available on Win32 systems.
SetFileAttributes()
int SetFileAttributes(string filename)
Set the file attributes for the specified file.
This function is only available on Win32 systems.
GetFileAttributes()
array(mixed) LookupAccountName(string|int(0..0) sys, string account)
This function is only available on some Win32 systems.
array(mixed) SetNamedSecurityInfo(string name, mapping(string:mixed) options)
This function is only available on some Win32 systems.
GetNamedSecurityInfo()
mapping(mixed:mixed) GetNamedSecurityInfo(string name, int|void type, int|void flags)
This function is only available on some Win32 systems.
SetNamedSecurityInfo()
void openlog(string ident, int options, facility)
Initializes the connection to syslogd.
The ident argument specifies an identifier to tag all logentries with.
A bitfield specifying the behaviour of the message logging. Valid options are:
|
Specifies what subsystem you want to log as. Valid facilities are:
|
Only available on systems with syslog(3).
LOG_NOWAIT should probably always be specified.
syslog , closelog
void syslog(int priority, string msg)
Writes the message msg to the log with the priorities in priority .
Priority is a bit vector with the wanted priorities or:ed together.
|
void closelog()
Document this function.
int setpwent()
Resets the getpwent function to the first entry in the passwd source using the systemfunction setpwent(3).
Always 0 (zero)
get_all_users() getpwent() endpwent()
int endpwent()
Closes the passwd source opened by getpwent function using the systemfunction endpwent(3).
Always 0 (zero)
get_all_users() getpwent() setpwent()
array(int|string) getpwent()
When first called, the getpwent function opens the passwd source and returns the first record using the systemfunction getpwent(3). For each following call, it returns the next record until EOF.
Call endpwent when done using getpwent .
An array with the information about the user
| ||||||||||||||||
0 if EOF.
get_all_users() getpwnam() getpwent() setpwent() endpwent()
int setgrent()
Rewinds the getgrent pointer to the first entry
get_all_groups() getgrent() endgrent()
int endgrent()
Closes the /etc/groups file after using the getgrent function.
get_all_groups() getgrent() setgrent()
array(int|string|array(string)) getgrent()
Get a group entry from /etc/groups file. getgrent interates thru the groups source and returns one entry per call using the systemfunction getgrent(3).
Always call endgrent when done using getgrent !
An array with the information about the group
| ||||||||||
get_all_groups() getgrnam() getgrgid()
void hardlink(string from, string to)
Create a hardlink named to from the file from .
This function is not available on all platforms.
symlink() , mv() , rm()
void symlink(string from, string to)
Create a symbolic link named to that points to from .
This function is not available on all platforms.
hardlink() , readlink() , mv() , rm()
string readlink(string path)
Returns what the symbolic link path points to.
This function is not available on all platforms.
symlink()
string resolvepath(string path)
Resolve all symbolic links of a pathname.
This function resolves all symbolic links, extra ``/'' characters and references to /./ and /../ in pathname , and returns the resulting absolute path, or 0 (zero) if an error occurs.
This function is not available on all platforms.
readlink() , symlink()
int umask(void|int mask)
Set the current umask to mask .
If mask is not specified the current umask will not be changed.
Returns the old umask setting.
void chmod(string path, int mode)
Sets the protection mode of the specified path.
Throws errors on failure.
Stdio.File->open() , errno()
void chown(string path, int uid, int gid)
Sets the owner and group of the specified path.
Throws errors on failure.
This function is not available on all platforms.
void utime(string path, int atime, int mtime)
Set the last access time and last modification time for the path path to atime and mtime repectively.
Throws errors on failure.
This function is not available on all platforms.
void initgroups(string name, int base_gid)
Initializes the supplemental group access list according to the system group database. base_gid is also added to the group access list.
Throws errors on failure.
This function is not available on all platforms.
setuid() , getuid() , setgid() , getgid() , seteuid() , geteuid() , setegid() , getegid() , getgroups() , setgroups()
void cleargroups()
Clear the supplemental group access list.
Throws errors on failure.
This function is not available on all platforms.
setgroups() , initgroups() , getgroups()
void setgroups(array(int) gids)
Set the supplemental group access list for this process.
Throws errors on failure.
This function is not available on all platforms.
initgroups() , cleargroups() , getgroups() , getgid() , getgid() , getegid() , setegid()
array(int) getgroups()
Get the current supplemental group access list for this process.
Throws errors on failure.
This function is not available on all platforms.
setgroups() , cleargroups() , initgroups() , getgid() , getgid() , getegid() , setegid()
int(0..1) innetgr(string netgroup, string|void machine, string|void user, string|void domain)
Searches for matching entries in the netgroup database (usually /etc/netgroup). If any of the machine , user or domain arguments are zero or missing, those fields will match any value in the selected netgroup .
This function isn't available on all platforms.
int setuid(int uid)
Sets the real user ID, effective user ID and saved user ID to uid .
Returns the current errno.
This function isn't available on all platforms.
getuid() , setgid() , getgid() , seteuid() , geteuid() , setegid() , getegid()
int setgid(int gid)
Sets the real group ID, effective group ID and saved group ID to gid .
If gid is -1 the uid for "nobody" will be used.
Throws an error if no "nobody" user when gid is -1.
Returns the current errno.
This function is not available on all platforms.
getuid() , setuid() , getgid() , seteuid() , geteuid() , setegid() , getegid()
int seteuid(int euid)
Set the effective user ID to euid . If euid is
-1 the uid for "nobody" will be used.
Returns the current errno.
Throws an error if there is no
"nobody" user when euid is -1.
This function isn't available on all platforms.
int setegid(int egid)
Set the effective group ID to egid . If egid is
-1 the uid for "nobody" will be used.
Returns the current errno.
Throws an error if there is no "nobody" user when
egid is -1.
This function isn't available on all platforms.
int getpgrp(int|void pid)
Get the process group id for the process pid . With no argguments or with 'pid' equal to zero, returns the process group ID of this process.
Not all platforms support getting the process group for other processes.
Not supported on all platforms.
getpid , getppid
int setpgrp()
Make this process a process group leader.
Not supported on all platforms.
int getsid(int|void pid)
Get the process session ID for the given process. If pid is not specified, the session ID for the current process will be returned.
This function is not available on all platforms.
Throws an error if the system call fails.
getpid , getpgrp , setsid
int setsid()
Set a new process session ID for the current process, and return it.
This function isn't available on all platforms.
Throws an error if the system call fails.
getpid , setpgrp , getsid
int(0..1) dumpable(int(0..1)|void val)
Get and/or set whether this process should be able to dump core.
Optional argument to set the core dumping state.
|
Returns 1 if this process currently is capable of dumping core,
and 0 (zero) if not.
This function is currently only available on some versions of Linux.
int setresuid(int ruid, int euid, int suid)
Sets the real, effective and saved set-user-ID to ruid , euid and suid respectively.
Returns zero on success and errno on failure.
int setresgid(int rgid, int egid, int sgid)
Sets the real, effective and saved group ID to rgid , egid and sgid respectively.
Returns zero on success and errno on failure.
int getuid()
Get the real user ID.
setuid , setgid , getgid , seteuid , geteuid , setegid , getegid
int getgid()
Get the real group ID.
setuid , getuid , setgid , seteuid , geteuid , getegid , setegid
int geteuid()
Get the effective user ID.
setuid , getuid , setgid , getgid , seteuid , getegid , setegid
int getegid()
Get the effective group ID.
setuid , getuid , setgid , getgid , seteuid , geteuid , setegid
int getpid()
Returns the process ID of this process.
getppid , getpgrp
int getppid()
Returns the process ID of the parent process.
getpid , getpgrp
int chroot(string newroot)
int chroot(Stdio.File newroot)
Changes the root directory for this process to the indicated directory.
A nonzero value is returned if the call is successful. If there's an error then zero is returned and errno is set appropriately.
Since this function modifies the directory structure as seen from Pike, you have to modify the environment variables PIKE_MODULE_PATH and PIKE_INCLUDE_PATH to compensate for the new root-directory.
This function only exists on systems that have the chroot(2) system call.
The second variant only works on systems that also have the fchroot(2) system call.
mapping(string:string) uname()
Get operating system information.
The resulting mapping contains the following fields:
|
This function only exists on systems that have the uname(2) or sysinfo(2) system calls.
Only the first five elements are always available.
string gethostname()
Returns a string with the name of the host.
This function only exists on systems that have the gethostname(2) or uname(2) system calls.
array(string|array(string)) gethostbyaddr(string addr)
Returns an array with information about the specified IP address.
The returned array contains the same information as that returned by gethostbyname() .
This function only exists on systems that have the gethostbyaddr(2) or similar system call.
gethostbyname()
array(string|array(string)) gethostbyname(string hostname)
Returns an array with information about the specified host.
The returned array contains the following:
| ||||||||
This function only exists on systems that have the gethostbyname(2) or similar system call.
gethostbyaddr()
int sleep(int seconds)
Call the system sleep() function.
This is not to be confused with the global function predef::sleep() that does more elaborate things and can sleep with better precision (although dependant on a normal functioning system clock).
The system's sleep function often utilizes the alarm(2) call and might not be perfectly thread safe in combination with simultaneous sleep()'s or alarm()'s. It might also be interrupted by other signals.
If you don't need it to be independant of the system clock, use predef::sleep() instead.
May not be present; only exists if the function exists in the current system.
predef::sleep() usleep() nanosleep()
void usleep(int usec)
Call the system usleep() function.
This is not to be confused with the global function predef::sleep() that does more elaborate things and can sleep with better precision (although dependant on a normal functioning system clock).
The system's usleep function often utilizes the alarm(2) call and might not be perfectly thread safe in combination with simultaneous sleep()'s or alarm()'s. It might also be interrupted by other signals.
If you don't need it to be independant of the system clock, use predef::sleep() instead.
May not be present; only exists if the function exists in the current system.
predef::sleep() sleep() nanosleep()
float nanosleep(int|float seconds)
Call the system nanosleep() function.
This is not to be confused with the global function predef::sleep() that does more elaborate things and can sleep with better precision (although dependant on a normal functioning system clock).
Returns the remaining time to sleep (as the system function does).
predef::sleep() sleep() usleep()
May not be present; only exists if the function exists in the current system.
array(int) getrlimit(string resource)
Returns the current process limitation for the selected resource .
|
| ||||||
This function nor all the resources are available on all systems.
getrlimits , setrlimit
mapping(string:array(int)) getrlimits()
Returns all process limits in a mapping.
getrlimit , setrlimit
int(0..1) setrlimit(string resource, int soft, int hard)
Sets the soft and the hard process limit on a resource .
getrlimit , getrlimits
void setproctitle(string title, mixed ... extra)
Sets the processes title.
constant System.ITIMER_REAL
Identifier for a timer that decrements in real time.
setitimer , getitimer
constant System.ITIMER_VIRTUAL
Identifier for a timer that decrements only when the process is executing.
setitimer , getitimer
constant System.ITIMER_PROF
Identifier for a timer that decrements both when the process is executing and when the system is executing on behalf of the process.
setitimer , getitimer
float setitimer(int timer, int|float value)
Sets the timer to the supplied value . Returns the current timer interval.
One of ITIMER_REAL , ITIMER_VIRTUAL and ITIMER_PROF .
array(float) getitimer(int timer)
Shows the state of the selected timer .
| ||||||
One of ITIMER_REAL , ITIMER_VIRTUAL and ITIMER_PROF .
array(string) get_netinfo_property(string domain, string path, string property)
Queries a NetInfo server for property values at the given path.
NetInfo domain. Use "." for the local domain.
NetInfo path for the property.
Name of the property to return.
An array holding all property values. If the path or property cannot be not found 0 is returned instead. If the NetInfo domain is not found or cannot be queried an exception is thrown.
system.get_netinfo_property(".", "/locations/resolver", "domain"); ({ "idonex.se" })
Only available on operating systems which have NetInfo libraries installed.
int rdtsc()
Executes the rdtsc (clock pulse counter) instruction and returns the result.
array(int) gettimeofday()
Calls gettimeofday(); the result is an array of seconds, microseconds, and possible tz_minuteswes, tz_dstttime as given by the gettimeofday(2) system call (read the man page).
time() , gethrtime()
constant System.string
This string constant tells whether or not the CPU time, returned by e.g. gethrvtime , is thread local or not. The value is "yes" if it is and "no" if it isn't. The value is also "no" if there is no thread support.
gethrvtime , gauge
constant System.int
The resolution of the CPU time, returned by e.g. gethrvtime , in
nanoseconds. It is -1 if the resolution isn't known.
gethrvtime , gauge
constant System.string
This string constant identifies the internal interface used to get the CPU time. It is an implementation detail - see rusage.c for possible values and their meanings.
gethrvtime , gauge
constant System.string
This string constant tells whether or not the high resolution real time returned by gethrtime , is monotonic or not. The value is "yes" if it is and "no" if it isn't.
Monotonic time is not affected by clock adjustments that might happen to keep the calendaric clock in synch. It's therefore more suited to measure time intervals in programs.
gethrtime
constant System.int
The resolution of the real time returned by gethrtime , in
nanoseconds. It is -1 if the resolution isn't known.
gethrtime
constant System.string
This string constant identifies the internal interface used to get the high resolution real time. It is an implementation detail - see rusage.c for possible values and their meanings.
gethrtime
mapping(string:int) getrusage()
Return resource usage about the current process. An error is thrown if it isn't supported or if the system fails to return any information.
Returns a mapping describing the current resource usage:
|
[1] Not if /proc rusage is used.
[2] Only from (Solaris?) /proc rusage.
[3] Only from /proc PRS usage.
On some systems, only utime will be filled in.
gethrvtime()
| CLASS System.Memory |
A popular demand is a class representing a raw piece of memory or a mmap'ed file. This is usually not the most effective way of solving a problem, but it might help in rare situations.
Using mmap can lead to segmentation faults in some cases. Beware, and read about mmap before you try anything. Don't blame Pike if you shoot your foot off.
void System.Memory()
void System.Memory(string|Stdio.File filename_to_mmap)
void System.Memory(int shmkey, int shmsize, int shmflg)
void System.Memory(int bytes_to_allocate)
Will call mmap() or allocate() depending on argument, either mmap'ing a file (in shared mode, writeable if possible) or allocating a chunk of memory.
int mmap(string|Stdio.File file)
int mmap(string|Stdio.File file, int offset, int size)
int mmap_private(string|Stdio.File file)
int mmap_private(string|Stdio.File file, int offset, int size)
mmap a file. This will always try to mmap the file in PROT_READ|PROT_WRITE, readable and writable, but if it fails it will try once more in PROT_READ only.
void allocate(int bytes)
void allocate(int bytes, int(0..255) fill)
void free()
Free the allocated or <tt>mmap</tt>ed memory.
int _sizeof()
returns the size of the memory (bytes). note: throws if not allocated
int(0..1) valid()
returns 1 if the memory is valid, 0 if not allocated
int(0..1) writeable()
returns 1 if the memory is writeable, 0 if not
string|array cast(string to)
Cast to string or array.
Throws if not allocated.
string pread(int(0..) pos, int(0..) len)
string pread16(int(0..) pos, int(0..) len)
string pread32(int(0..) pos, int(0..) len)
string pread16i(int(0..) pos, int(0..) len)
string pread32i(int(0..) pos, int(0..) len)
string pread16n(int(0..) pos, int(0..) len)
string pread32n(int(0..) pos, int(0..) len)
Read a string from the memory. The 16 and 32 variants reads widestrings, 16 or 32 bits (2 or 4 bytes) wide, the i variants in intel byteorder, the normal in network byteorder, and the n variants in native byteorder.
len is the number of characters, wide or not. pos is the byte position (!).
int pwrite(int(0..) pos, string data)
int pwrite16(int(0..) pos, string data)
int pwrite32(int(0..) pos, string data)
int pwrite16i(int(0..) pos, string data)
int pwrite32i(int(0..) pos, string data)
Write a string to the memory (and to the file, if it's mmap()ed). The 16 and 32 variants writes widestrings, 16 or 32 bits (2 or 4 bytes) wide, the 'i' variants in intel byteorder, the other in network byteorder.
returns the number of bytes (not characters) written
int `[](int pos)
string `[](int pos1, int pos2)
int `[]=(int pos, int char)
string `[]=(int pos1, int pos2, string str)
| CLASS System.Time |
The current time as a structure containing a sec and a usec member.
int System.Time.sec
int System.Time.usec
The number of seconds and microseconds since the epoch and the last whole second, respectively. (See also predef::time() )
Please note that these variables will continually update when they are requested, there is no need to create new Time() objects.
int System.Time.usec_full
The number of microseconds since the epoch. Please note that pike has to have been compiled with bignum support for this variable to contain sensible values.
void System.Time(int fast)
If fast is true, do not request a new time from the system, instead use the global current time variable.
This will only work in callbacks, but can save significant amounts of CPU.
| CLASS System.Timer |
float peek()
Return the time in seconds since the last time get was called.
float get()
Return the time in seconds since the last time get was called. The first time this method is called the time since the object was created is returned instead.
void System.Timer(int|void fast)
Create a new timer object. The timer keeps track of relative time with sub-second precision.
If fast is specified, the timer will not do system calls to get the current time but instead use the one maintained by pike. This will result in faster but more or less inexact timekeeping. The pike maintained time is only updated when a Pike.Backend object stops waiting and starts executing code.
| Module PDF |
constant PDF.a0_width
constant PDF.a0_height
constant PDF.a1_width
constant PDF.a1_height
constant PDF.a2_width
constant PDF.a2_height
constant PDF.a3_width
constant PDF.a3_height
constant PDF.a4_width
constant PDF.a4_height
constant PDF.a5_width
constant PDF.a5_height
constant PDF.a6_width
constant PDF.a6_height
constant PDF.b5_width
constant PDF.b5_height
constant PDF.letter_width
constant PDF.letter_height
constant PDF.legal_width
constant PDF.legal_height
constant PDF.ledger_width
constant PDF.ledger_height
constant PDF.p11x17_width
constant PDF.p11x17_height
| CLASS PDF.PDFgen |
int open_file(string filename)
PDF close()
PDF begin_page()
PDF begin_page(float width, float height)
note: Defaults to a4, portrait
PDF end_page()
float get_value(string key)
float get_value(string key, float modifier)
float set_value(string key, float value)
string get_parameter(string key)
string get_parameter(string key, float modifier)
float set_parameter(string key, string parameter)
float set_info(string key, string info)
int findfont(string fontname)
int findfont(string fontname, void|string encoding, void|int embed)
PDF setfont(int n, float size)
PDF show(string s)
PDF showxy(string s, float x, float y)
PDF continue_text(string s)
int show_boxed(string text, float x, float y, float width, float height, string mode)
int show_boxed(string text, float x, float y, float width, float height, string mode, string feature)
float stringwidth(string text, int font, float size)
object set_text_pos(float x, float y)
object setdash(float b, float w)
object setflat(float flatness)
object setlinejoin(int linejoin)
object setlinecap(int linecap)
object setmiterlimit(float miter)
object setlinewidth(float width)
object translate(float tx, float ty)
object scale(float sx, float sy)
object rotate(float phi)
object skew(float alpha, float beta)
object concat(float a, float b, float c, float d, float e, float f)
object moveto(float x, float y)
object lineto(float x, float y)
object curveto(float x1, float y1, float x2, float y2, float x3, float y3)
object circle(float x, float y, float r)
object arc(float x, float y, float r, float start, float end)
object rect(float x, float y, float width, float height)
object setgray_fill(float gray)
object setgray_stroke(float gray)
object setgray(float gray)
object setrgbcolor_fill(float red, float green, float blue)
object setrgbcolor_stroke(float red, float green, float blue)
object setrgbcolor(float red, float green, float blue)
int open_image_file(string type, string filename)
int open_image_file(string type, string filename, void|string stringparam, void|int intparam)
int open_CCITT(string filename, int width, int height, int BitReverse, int K, int BlackIs1)
int open_image(string type, string source, string data, int width, int height, int components, int bpc, string params)
object close_image(int image)
object place_image(int image, float x, float y, float scale)
int add_bookmark(string text, int parent, int open)
object attach_file(float llx, float lly, float urx, float ury, string filename, string description, string author, string mimetype, string icon)
object add_pdflink(float llx, float lly, float urx, float ury, string filename, int page, string dest)
object add_locallink(float llx, float lly, float urx, float ury, int page, string dest)
object add_launchlink(float llx, float lly, float urx, float ury, string filename)
object add_weblink(float llx, float lly, float urx, float ury, string url)
object set_border_style(string style, float width)
object set_border_color(float red, float green, float blue)
object set_border_dash(float b, float w)
| Module Fuse |
Fuse - Filesystem in USErspace
FUSE (Filesystem in USErspace) provides a simple interface for userspace programs to export a virtual filesystem to the Linux kernel. FUSE also aims to provide a secure method for non privileged users to create and mount their own filesystem implementations.
FUSE is only available on Linux.
See http://sourceforge.net/projects/fuse/ for more information
This module maps the Fuse library more or less directly to pike.
A tip: /usr/include/asm/errno.h can be included in pike programs on Linux.
inherit "___Fuse"
void run(Operations handler, array(string) args)
Start fuse. Args is as in argv in main().
The first argument (argv[0], program name) is used as the filesystem name.
The first non-flag argument after argv[0] is used as the mountpoint.
Otherwise these arguments are supported:
-d enable debug output (implies -f)
-f foreground operation
-s disable multithreaded operation
-r mount read only (equivalent to '-o ro')
-o opt,[opt...] mount options
-h print help
Mount options:
default_permissions enable permission checking
allow_other allow access to other users
allow_root allow access to root
kernel_cache cache files in kernel
large_read issue large read requests (2.4 only)
direct_io use direct I/O
max_read=N set maximum size of read requests (default 128K)
hard_remove immediate removal (don't hide files)
debug enable debug output
fsname=NAME set filesystem name in mtab (overrides argv[0])
| CLASS Fuse.Operations |
This is the interface you have to implement to write a FUSE filesystem If something goes wrong in your callback, always return errno. Unless the function returns a specific value (Stat, string or similar), return 0 if all is well.
You do not have to implement all functions. Unimplemented functions have a default implementation that returns -ENOIMPL.
constant Fuse.Operations.DT_UNKNOWN
Unkown directory entry type
constant Fuse.Operations.DT_FIFO
FIFO directory entry
constant Fuse.Operations.DT_CHR
Character special directory entry
constant Fuse.Operations.DT_DIR
Directory directory entry
constant Fuse.Operations.DT_BLK
Block special directory entry
constant Fuse.Operations.DT_REG
Normal file directory entry
constant Fuse.Operations.DT_LNK
Symlink directory entry
constant Fuse.Operations.DT_SOCK
Socket directory entry
constant Fuse.Operations.O_APPEND
Open for append
constant Fuse.Operations.O_ACCMODE
Mask for read/write/rdwr
constant Fuse.Operations.O_RDONLY
Open read only
constant Fuse.Operations.O_WRONLY
Open write only
constant Fuse.Operations.O_RDWR
Open read/write only
Stdio.Stat|int(1..) getattr(string path)
Stat a file.
This function is required.
The symlink contents or errno
string|int(1..) readlink(string path)
Read a symlink.
The symlink contents or errno
int readdir(string path, function(string:void) callback)
Get directory contents. The callback get the filename.
This function is required.
errno or 0
int mknod(string path, int mode, int rdev)
Create a node (file, device special, or named pipe). See man 2 mknod
errno or 0
int mkdir(string path, int mode)
Create a directory.
errno or 0
int unlink(string path)
Remove a file
errno or 0
int rmdir(string path)
Remove a directory
errno or 0
int symlink(string source, string destination)
Create a symlink from source to destination.
errno or 0
int link(string source, string destination)
Create a hard link from source to destination.
errno or 0
int rename(string source, string destination)
Rename source to destination .
errno or 0
int chmod(string path, int mode)
Change mode
errno or 0
int chown(string path, int uid, int gid)
Change owner
errno or 0
int truncate(string path, int new_length)
Shrink or enlarge file
errno or 0
int utime(string path, int atime, int mtime)
Set access and modification time
errno or 0
int open(string path, int mode)
Open path . mode is as for the system call open. (mode & O_ACCMODE) is one of O_RDONLY, O_WRONLY and O_RDWR. The mode can also contain other flags, most notably O_APPEND.
You do not really have to implement this function. It's useful to start prefetch and to cache open files, and check that the user has permission to read/write the file.
errno or 0
string|int(1..) read(string path, int len, int offset)
Read data from a file. You have to return at most len bytes, unless an error occurs.
errno or data
int write(string path, string data, int offset)
Write data to the file. Should write all data.
errno or amount written (bytes)
mapping(string:int) statfs(string path)
Stat a filesystem. Mapping as from filesystem_stat
required for 'df' support, without this function there is an error each time 'df' is run.
int release(string path)
The inverse of open.
The file might very well be openend multiple times. Keep reference counts.
int fsync(string path, int datasync)
Flush data and user-data to disk. Not required. If the datasync parameter is non-zero, then only the user data should be flushed, not the meta data.
array(string)|int listxattr(string path)
Return a list of all available extended attributes on path
int removexattr(string path, string name)
Remove the extended attribute name from path
string getxattr(string path, string name)
Get the extended attribute name on path
int setxattr(string path, string name, string value, int flags)
Set the extended attribute name on path to value
int creat(string path, int mode, int flag)
Create and open or just open the given path
int access(string path, int mode)
Return if the user is allowed to access the path . If the 'default_permissions' mount option is given, this method is not called.
int flush(string path, int flags)
Write unwritten data.
| Module _Ffmpeg |
constant _Ffmpeg.CODEC_ID_NONE
constant _Ffmpeg.CODEC_ID_AC3
constant _Ffmpeg.CODEC_ID_ADPCM_IMA_QT
constant _Ffmpeg.CODEC_ID_ADPCM_IMA_WAV
constant _Ffmpeg.CODEC_ID_ADPCM_MS
constant _Ffmpeg.CODEC_ID_H263
constant _Ffmpeg.CODEC_ID_H263I
constant _Ffmpeg.CODEC_ID_H263P
constant _Ffmpeg.CODEC_ID_MJPEG
constant _Ffmpeg.CODEC_ID_MPEG1VIDEO
constant _Ffmpeg.CODEC_ID_MPEG4
constant _Ffmpeg.CODEC_ID_MP2
constant _Ffmpeg.CODEC_ID_MP3LAME
constant _Ffmpeg.CODEC_ID_MSMPEG4V1
constant _Ffmpeg.CODEC_ID_MSMPEG4V2
constant _Ffmpeg.CODEC_ID_MSMPEG4V3
constant _Ffmpeg.CODEC_ID_PCM_ALAW
constant _Ffmpeg.CODEC_ID_PCM_MULAW
constant _Ffmpeg.CODEC_ID_PCM_S16BE
constant _Ffmpeg.CODEC_ID_PCM_S16LE
constant _Ffmpeg.CODEC_ID_PCM_S8
constant _Ffmpeg.CODEC_ID_PCM_U16BE
constant _Ffmpeg.CODEC_ID_PCM_U16LE
constant _Ffmpeg.CODEC_ID_PCM_U8
constant _Ffmpeg.CODEC_ID_RAWVIDEO
constant _Ffmpeg.CODEC_ID_RV10
constant _Ffmpeg.CODEC_ID_SVQ1
constant _Ffmpeg.CODEC_ID_VORBIS
constant _Ffmpeg.CODEC_ID_WMV1
constant _Ffmpeg.CODEC_ID_WMV2
Various audio and video codecs.
The list of supported codecs depends on Ffmpeg library.
constant _Ffmpeg.CODEC_TYPE_AUDIO
constant _Ffmpeg.CODEC_TYPE_VIDEO
Type of codec.
| CLASS _Ffmpeg.ffmpeg |
Implements support of all codecs from a nice project Ffmpeg. You can find more info about it at http://ffmpeg.sf.net/.
void _Ffmpeg.ffmpeg(int codec_name, int encoder)
Create decoder or encoder object.
Internal number of codec, eg. CODEC_ID_MP2 .
If true, encoder object will be created, decoder object otherwise.
mapping|int get_codec_info()
Returns mapping with info of used codec.
list_codecs()
int set_codec_param(string name, mixed value)
Sets one codec parameter
The name of parameter. One of "sample_rate",
"bit_rate", "channels".
Returns 1 on success, 0 otherwise (parameter not known).
get_codec_params()
mapping|int get_codec_status()
Returns a mapping with the actual codec parameters.
set_codec_param()
mapping|int decode(string data)
Returns a mapping with the new decoded frame and lenght of data which was used for decoding.
int decode(string data, function shuffler)
Decode all data buffer and pass result to shuffler .
Returns 1 on success, 0 otherwise.
Shuffler variant isn't implemented, yet.
Usable only in decoder.
create()
array(mapping) list_codecs()
Gets all supported codecs.
Array of mapping with codec features.
| Module _Roxen |
string make_http_headers(mapping(string:string|array(string)) headers, int(0..1)|void no_terminator)
string http_decode_string(string encoded)
Decodes an http transport-encoded string.
string html_encode_string(mixed in)
Encodes the in data as an HTML safe string.
| CLASS _Roxen.HeaderParser |
array(string|mapping) feed(string data)
void _Roxen.HeaderParser()
| Module spider |
array(mapping(string:int)|int) parse_accessed_database(string database)
string parse_html(string html, mapping(string:function(string:string|array)) tag_callbacks, mapping(string:function(string:string|array)) container_callbacks, mixed ... extras)
string parse_html_lines(string html, mapping(string:function(string:string|array)) tag_callbacks, mapping(string:function(string:string|array)) container_callbacks, mixed ... extras)
void set_end_quote(int quote)
void set_start_quote(int quote)
array(int) get_all_active_fds()
string fd_info(int fd)
string _low_program_name(program prog)
array(array(string|int)) _dump_obj_table()
string discdate(int time)
string stardate(int time, int precision)
| Module Java |
inherit "___Java"
jobject JString(string s)
jobject JBoolean(int i)
jobject JInteger(int i)
jobject JFloat(float f)
jobject JHashMap(mapping m)
jobject JArray(array a)
| Module Math |
inherit "___Math"
int|float convert_angle(int|float angle, string from, string to)
This function converts between degrees, radians and gons. The from and to arguments may be any of the follwoing strings: "deg", "rad", "gon" and "str" for degrees, radians, gon and streck respectivly. The output is not guaranteed to be within the first turn, e.g. converting 10 radians yields almost 573 degrees as output.
int choose(int n, int k)
Calculate binomial koefficient n choose k .
This is equvivalent to n !/(k !*(n -k )!).
float log10(float x)
The 10-logarithm of x .
float log2(float x)
The 2-logarithm of x .
float logn(float n, float x)
The n -logatirhm of x .
array(int) factor(int x)
Factorize the integer x . The returned list of factors will be sorted biggest to smallest factor.
This function is only available when Pike has been compiled with bignums.
constant Math.pi
The constant pi (3.14159265358979323846).
constant Math.e
The constant e (2.7182818284590452354).
constant Math.inf
Floating point infinity.
constant Math.nan
Floating point not-a-number (e.g. inf/inf).
| CLASS Math.Angle |
Represents an angle.
int|float Math.Angle.angle
The actual keeper of the angle value.
string Math.Angle.type
The type of the angle value. Is either "deg", "rad", "gon" or "str".
void Math.Angle()
void Math.Angle(int|float radians)
void Math.Angle(int|float angle, string type)
If an angle object is created without arguments it will have the value 0 radians.
Angle clone_me()
Returns a copy of the object.
int|float get(string type)
Gets the value in the provided type.
Angle set(string type, int|float _angle)
Sets the angle value and type to the given value and type.
void normalize()
Normalizes the angle to be within one turn.
int|float degree()
Returns the number of degrees, including minutes and seconds as decimals.
int minute()
Returns the number of minute.
float second()
Returns the number of seconds.
Angle set_dms(int degrees)
Angle set_dms(int degrees, int minutes)
Angle set_dms(int degrees, int minutes, float seconds)
Set degrees, minues and seconds. Returns the current angle object.
string format_dms()
Returns degrees, minutes and seconds as a string, e.g. 47°6'36.00".
Angle set_degree(int|float degree)
Sets the angle to the provided degree. Alters the type to degrees. Returns the current object.
int|float gon()
Returns the number of gons.
Angle set_gon(int|float gon)
Set the angle to the provided gons. Alters the type to gons. Returns the current angle object.
float rad()
Returns the number of radians.
Angle set_rad(int|float rad)
Set the angle to the provided radians. Alters the type to radians. Returns the current angle object.
float|int streck()
Returns the number of strecks.
Angle set_streck(int|float str)
Set the angle to the provided strecks. Alters the type to streck. Returns the current angle object.
void about_face()
Turns the direction of the angle half a turn. Equal to
add(180,"deg").
void right_face()
Turns the direction of the angle a quarter of a turn to the right.
Equal to subtract(90,"deg").
void left_face()
Turns the direction of the angle a quarter of a turn to the left.
Equal to add(90,"deg").
float sin()
Returns the sinus for the angle.
float cos()
Returns the cosinus for the angle.
float tan()
Returns the tangen for the angle.
float|int|string cast(string to)
An angle can be casted to float, int and string.
float|int|Angle `+(float|int|Angle _angle)
Returns the sum of this angle and what it is added with. If added with an angle, a new angle object is returnes.
Angle add(float|int angle)
Angle add(float|int angle, string type)
Angle add(Angle angle)
Adds the provided angle to the current angle. The result is normalized within 360 degrees.
float|int|Angle `-(float|int|Angle _angle)
Returns the difference between this angle and the provided value. If differenced with an angle, a new angle object is returned.
Angle subtract(float|int angle)
Angle subtract(float|int angle, string type)
Angle subtract(Angle angle)
Subtracts the provided angle from the current angle. The result is normalized within 360 degrees.
float|int|Angle `*(float|int|Angle _angle)
Returns the product between this angle and the provided value. If differenced with an angle, a new angle object is returned.
float|int|Angle `/(float|int|Angle _angle)
Returns the fraction between this angle and the provided value. If differenced with an angle, a new angle object is returned.
float|int|Angle `%(float|int|Angle _angle)
Returns this result of this angle modulo the provided value. If differenced with an angle, a new angle object is returned.
int __hash()
int `==(Angle _angle)
Compares the unnormalized angle of two Angle objects.
int `<(Angle _angle)
Compares the unnormalized angle of two Angle objects.
int `>(Angle _angle)
Compares the unnormalized angle of two Angle objects.
| CLASS Math.Matrix |
Matrix representation with double precision floating point values.
void Math.Matrix(array(array(int|float)) matrix_2d)
void Math.Matrix(array(int|float) matrix_1d)
Initializes the matrix as a 1D or 2D matrix, e.g.
Math.Matrix( ({({1,2}),({3,4})}) ).
void Math.Matrix(int n, int m)
void Math.Matrix(int n, int m, string type)
void Math.Matrix(int n, int m, float|int init)
Initializes the matrix as to be a n *m matrix with init in
every value. If no third argument is given, or the third argument
is "identity", the matrix will be initialized with all
zeroes except for the diagonal which will be 1.
void Math.Matrix(string type, int size)
When type is "identity" the matrix is initializes as a
square identity matrix.
void Math.Matrix(string type, int size, float rads, Matrix axis)
void Math.Matrix(string type, int size, float rads, float x, float y, float z)
When type is "rotate" the matrix is initialized as a
rotation matrix.
array(array) cast(string to_what)
array(array) cast(string to_what)
It is possible to cast the matrix to an array and get back a double array of floats with the matrix values.
vect
array vect()
Return all the elements of the matrix as an array of numbers
Matrix transpose()
Returns the transpose of the matrix as a new object.
float norm()
float norm2()
Matrix normv()
Norm of the matrix, and the square of the norm of the matrix. (The later method is because you may skip a square root sometimes.)
This equals |A| or sqrt( A02 + A12 + ... + An2 ).
It is only usable with 1xn or nx1 matrices.
m->normv() is equal to m*(1.0/m->norm()),
with the exception that the zero vector will still be
the zero vector (no error).
Matrix `+(object with)
Matrix ``+(object with)
Matrix add(object with)
Add this matrix to another matrix. A new matrix is returned. The matrices must have the same size.
Matrix `-()
Matrix `-(object with)
Matrix ``-(object with)
Matrix sub(object with)
Subtracts this matrix from another. A new matrix is returned.
-m is equal to -1*m.
Matrix sum()
Produces the sum of all the elements in the matrix.
Matrix max()
Matrix min()
Produces the maximum or minimum value of all the elements in the matrix.
Matrix `*(object with)
Matrix ``*(object with)
Matrix mult(object with)
Matrix multiplication.
Matrix cross(object with)
Matrix cross-multiplication.
float dot_product(object with)
Matrix dot product.
Matrix convolve(object with)
Convolve called matrix with the argument.
int xsize()
Returns the width of the matrix.
int ysize()
Returns the height of the matrix.
| CLASS Math.FMatrix |
Matrix representation with single precision floating point values.
inherit Matrix : Matrix
| CLASS Math.LMatrix |
Matrix representation with 64 bit integer values.
inherit Matrix : Matrix
| CLASS Math.IMatrix |
Matrix representation with 32 bit integer values.
inherit Matrix : Matrix
| CLASS Math.SMatrix |
Matrix representation with 16 bit integer values.
inherit Matrix : Matrix
| Module Math.Transforms |
| CLASS Math.Transforms.FFT |
array(array(float)) rFFT(array(int|float) real_input)
Returns the FFT of the input array. The input must be real and the output is complex. The output consists of an array. It's first element is the amplitudes and the second element is the phases.
The array of floats and/or ints to transform.
rIFFT(rFFT()) returns the input array scaled by n=sizeof(input array). This is due to the nature of the DFT algorithm.
rIFFT()
array(float) rIFFT(array(array(float)) input)
Returns the inverse FFT of the input array. The input must be complex and guaranteed to generate a real output.
The input is an array. It's first element is the amplitudes and the second element is the phases.
The output is an array of the real values for the iFFT.
The array of floats and/or ints to transform.
rIFFT(rFFT()) returns the input array scaled by n=sizeof(input array). This is due to the nature of the DFT algorithm.
rFFT()
void Math.Transforms.FFT(void|int n, void|int(0..1) exact)
Creates a new transform object. If n is specified, a plan is created for transformations of n-size arrays.
Size of the transform to be preformed. Note that the transform object will be initialized for this size, but if an array of different size is sent to the object, it will be reinitialized. This can be used to gain preformace if all transforms will be of a given size.
If exact is 1, a "better" plan for the transform will be created. This will take more time though. Use only if preformance is needed.
| Module Postgres |
| CLASS Postgres.postgres |
This is an interface to the Postgres (Postgres95, pgsql) database server. This module may or may not be availible on your Pike, depending whether the appropriate include and library files could be found at compile-time. Note that you do not need to have a Postgres server running on your host to use this module: you can connect to the database over a TCP/IP socket.
Please notice that unless you wish to specifically connect to a Postgres server, you'd better use the Sql.Sql , which is a server-independent sql-server-class. The interfaces to all existing sql-classes are consistent. Using Sql.Sql ensures that your Pike applications will run with any supported SQL server without changing a single line of code, at least for most common (and simple) operations.
The program Postgres.postgres provides the raw interface to the database. Many functions are not availible for this program. Therefore, its use is DEPRECATED. It is included in this documentation only for completeness' sake. Use Sql.postgres instead, or even better Sql.Sql
There is no testsuite for this module, since to test anything would require a working Postgres server. You can try to use the included scripts in the "pike/src/modules/Postgres/extras" directory but you'll probably have to patch them to reflect your site's settings.
Also note that this module uses blocking I/O I/O to connect to the server. Postgres is quite slow, and so you might want to consider this particular aspect. It is (at least should be) thread-safe, and so it can be used in a multithread environment.
The behavior of the Postgres C API also depends on certain environment variables defined in the environment of the pike interpreter.
|
Refer to the Postgres documentation for further details.
Sql.Sql , Sql.postgres , Sql.postgres_result
string Postgres.postgres.version
Should you need to report a bug to the author, please submit along with the report the driver version number, as returned by this call.
void Postgres.postgres()
void Postgres.postgres(string host, void|string database, void|int port)
With no arguments, this function initializes (reinitializes if a connection had been previously set up) a connection to the Postgres backend. Since Postgres requires a database to be selected, it will try to connect to the default database. The connection may fail however for a variety of reasons, in this case the most likely of all is because you don't have enough authority to connect to that database. So use of this particular syntax is discouraged.
The host argument allows you to connect to databases residing on different hosts. If it is 0 or "", it will try to connect to localhost.
The database argument specifies the database to connect to. If 0 or "", it will try to connect to the default database.
You need to have a database selected before using the sql-object, otherwise you'll get exceptions when you try to query it. Also notice that this function can raise exceptions if the db server doesn't respond, if the database doesn't exist or is not accessible by you.
You don't need bothering about syncronizing the connection to the database: it is automatically closed (and the database is sync-ed) when the object is destroyed.
Sql.postgres , Sql.Sql , select_db
void select_db(string dbname)
This function allows you to connect to a database. Due to restrictions of the Postgres frontend-backend protocol, you always have to be connected to a database, so in fact this function just allows you to connect to a different database on the same server.
This function can raise exceptions if something goes wrong (backend process not running, not enough permissions..)
create
Sql.postgres_result big_query(string sqlquery)
This is the only provided interface which allows you to query the database. If you wish to use the simpler "query" function, you need to use the Sql.Sql generic sql-object.
It returns a postgres_result object (which conforms to the Sql.sql_result standard interface for accessing data). I recommend using query() for simpler queries (because it is easier to handle, but stores all the result in memory), and big_query for queries you expect to return huge amounts of data (it's harder to handle, but fectches results on demand).
This function can raise exceptions.
The program Sql.postgres_result is a superset of the raw Postgres.postgres_result which does not do chunking to avoid excessive memory usage in case of large resultsets.
Sql.Sql , Sql.sql_result
string error()
This function returns the textual description of the last server-related error. Returns 0 if no error has occurred yet. It is not cleared upon reading (can be invoked multiple times, will return the same result until a new error occurs).
big_query
void reset()
This function resets the connection to the backend. Can be used for a variety of reasons, for example to detect the status of a connection.
This function is Postgres-specific, and thus it is not availible through the generic SQL-interface.
void _set_notify_callback()
void _set_notify_callback(function f)
With Postgres you can associate events and notifications to tables. This function allows you to detect and handle such events.
With no arguments, resets and removes any callback you might have put previously, and any polling cycle.
With one argument, sets the notification callback (there can be only one for each sqlobject).
The callback function must return no value, and takes a string argument, which will be the name of the table on which the notification event has occured. In future versions, support for user-specified arguments will be added.
The Sql.postgres program adds support for automatic delivery of messages (see it for explanation on the inner workings of this feature).
This function is Postgres-specific, and thus it is not availible through the generic SQL-interface
Sql.postgres
string host_info()
This function returns a string describing what host are we talking to, and how (TCP/IP or UNIX sockets).
int affected_rows()
This function returns the number of rows affected by the last query.
string _quote(string s)
Escape a string to prevent SQL injection, using the current connection's character encoding settings.
| CLASS Postgres.postgres_result |
Contains the result of a Postgres-query.
Sql.postgres, Postgres.postgres, Sql.Sql, Sql.sql_result
void Postgres.postgres_result(object o)
You can't create istances of this object yourself. The only way to create it is via a big_query to a Postgres database.
int num_rows()
Returns the number of rows in the result.
int num_fields()
Returns the number of fields in the result.
array(mapping(string:mixed)) fetch_fields()
Returns an array with an entry for each field, each entry is a mapping with the following fields:
|
For char() fields, length is to be intended as the MAXIMUM length of the field. This is not part of the interface specifications in fact, but a driver-choice. In fact char() fields are for Postgres _FIXED_ length fields, and are space-padded. If CUT_TRAILING_SPACES is defined when the driver is compiled (default behavior) it will cut such spaces.
void seek()
Moves the result cursor (ahead or backwards) the specified number of rows. Notice that when you fetch a row, the cursor is automatically moved forward one slot.
array(string) fetch_row()
Returns an array with the contents of the next row in the result. Advances the row cursor to the next row. Returns 0 at end of table.
Since there's no generic way to know whether a type is numeric or not in Postgres, all results are returned as strings. You can typecast them in Pike to get the numeric value.
seek()
| Module SANE |
This module enables access to the SANE (Scanner Access Now Easy) library from pike
array(mapping) list_scanners()
Returns an array with all available scanners.
Pike v0.7 release 120 running Hilfe v2.0 (Incremental Pike Frontend) > SANE.list_scanners(); Result: ({ ([ "model":"Astra 1220S ", "name":"umax:/dev/scg1f", "type":"flatbed scanner", "vendor":"UMAX " ]), ([ "model":"Astra 1220S ", "name":"net:lain.idonex.se:umax:/dev/scg1f", "type":"flatbed scanner", "vendor":"UMAX " ]) })
constant SANE.FrameGray
constant SANE.FrameRGB
constant SANE.FrameRed
constant SANE.FrameGreen
constant SANE.FrameBlue
| CLASS SANE.Scanner |
void SANE.Scanner(string name)
array(mapping) list_options()
This method returns an array where every element is a mapping, layed out as follows.
|
void set_option(string name, mixed new_value)
void set_option(string name)
If no value is specified, the option is set to it's default value
mixed get_option(string name)
mapping(string:int) get_parameters()
|
Image.Image simple_scan()
void row_scan(function(Image.Image:void) callback)
void nonblocking_row_scan(function(Image.Image:void) callback)
void cancel_scan()
| Module DefaultCompilerEnvironment |
The CompilerEnvironment object that is used for loading C-modules and by predef::compile() .
predef::compile() is essentially an alias for the CompilerEnvironment()->compile() in this object.
CompilerEnvironment , predef::compile()
| Module Multiset |
| CLASS Multiset.Iterator |
An object of this class is returned by get_iterator() when called with a multiset.
get_iterator
inherit predef::Iterator : predef::Iterator
| Namespace 7.2:: |
Pike 7.2 compatibility.
The symbols in this namespace will appear in
programs that use #pike 7.2 or lower.
inherit 7.4:: :
string dirname(string path)
Remove the last segment from path .
This implementation differs from predef::dirname()
in that it will return "" for the input "/"
while predef::dirname() will return "/".
predef::dirname()
void sleep(float|int t, void|int abort)
High-resolution sleep (Pike 7.2 compatibility).
Sleep t seconds. This function was renamed to delay() in Pike 7.3.
This function will busy-wait if the sleep-interval is short.
predef::sleep() , delay()
string default_yp_domain()
Get the default YP domain (Pike 7.2 compatibility). This function was removed in Pike 7.3, use Yp.default_domain() instead.
Yp.default_domain()
object new(string|program prog, mixed ... args)
Instantiate a program (Pike 7.2 compatibility).
A new instance of the class prog will be created. All global variables in the new object be initialized, and then lfun::create() will be called with args as arguments.
This function was removed in Pike 7.3, use
((program)prog )(@args )
instead.
destruct() , compile_string() , compile_file() , clone()
object clone(string|program prog, mixed ... args)
Alternate name for the function new() (Pike 7.2 compatibility).
This function was removed in Pike 7.3, use
((program)prog )(@args )
instead.
destruct() , compile_string() , compile_file() , new()
| Module LR |
| CLASS LR.parser |
This object implements an LALR(1) parser and compiler.
Normal use of this object would be:
{add_rule, set_priority, set_associativity}*
set_symbol_to_string
compile
{parse}*
mapping(int|string:array(rule)) LR.parser.grammar
The grammar itself.
kernel LR.parser.start_state
The initial LR0 state.
int LR.parser.verbose
Verbosity level
|
int LR.parser.error
Error code
mapping(string:kernel) LR.parser.known_states
LR0 states that are already known to the compiler.
string rule_to_string(rule r)
Pretty-prints a rule to a string.
Rule to print.
string item_to_string(item i)
Pretty-prints an item to a string.
Item to pretty-print.
string state_to_string(kernel state)
Pretty-prints a state to a string.
State to pretty-print.
string cast_to_string()
Pretty-prints the current grammar to a string.
mixed cast(string type)
Implements casting.
Type to cast to.
void set_priority(string terminal, int pri_val)
Sets the priority of a terminal.
Terminal to set the priority for.
Priority; higher = prefer this terminal.
void set_associativity(string terminal, int assoc)
Sets the associativity of a terminal.
Terminal to set the associativity for.
Associativity; negative - left, positive - right, zero - no associativity.
void set_symbol_to_string(void|function(int|string:string) s_to_s)
Sets the symbol to string conversion function. The conversion function is used by the various *_to_string functions to make comprehensible output.
Symbol to string conversion function. If zero or not specified, use the built-in function.
void add_rule(rule r)
Add a rule to the grammar.
Rule to add.
state_queue LR.parser.s_q
Contains all states used. In the queue-part are the states that remain to be compiled.
int compile()
Compiles the grammar into a parser, so that parse() can be called.
mixed parse(object|function(void:string|array(string|mixed)) scanner, void|object action_object)
Parse the input according to the compiled grammar. The last value reduced is returned.
The parser must have been compiled (with compile()) prior to calling this function.
Errors should be throw()n.
The scanner function. It returns the next symbol from the input. It should either return a string (terminal) or an array with a string (terminal) and a mixed (value). EOF is indicated with the empty string.
Object used to resolve those actions that have been specified as strings.
| CLASS LR.parser.kernel |
Implements an LR(1) state
multiset(rule) LR.parser.kernel.rules
Used to check if a rule already has been added when doing closures.
array(item) LR.parser.kernel.items
Contains the items in this state.
mapping(int:item) LR.parser.kernel.item_id_to_item
Used to lookup items given rule and offset
mapping(int:multiset(item)) LR.parser.kernel.symbol_items
Contains the items whose next symbol is this non-terminal.
mapping(int|string:kernel|rule) LR.parser.kernel.action
The action table for this state
object(kernel) SHIFT to this state on this symbol.
object(rule) REDUCE according to this rule on this symbol.
multiset LR.parser.kernel.closure_set
The symbols that closure has been called on.
void add_item(item i)
Add an item to the state.
void closure(int nonterminal)
Make the closure of this state.
Nonterminal to make the closure on.
multiset(int|string) goto_set()
Make the goto-set of this state.
kernel do_goto(int|string symbol)
Generates the state reached when doing goto on the specified symbol. i.e. it compiles the LR(0) state.
Symbol to make goto on.
| CLASS LR.parser.state_queue |
This is a queue, which keeps the elements even after they are retrieved.
int LR.parser.state_queue.head
Index of the head of the queue.
int LR.parser.state_queue.tail
Index of the tail of the queue.
array(kernel) LR.parser.state_queue.arr
The queue itself.
kernel push(kernel state)
Pushes the state on the queue.
State to push.
int|kernel next()
Return the next state from the queue.
| CLASS LR.rule |
This object is used to represent a BNF-rule in the LR parser.
int LR.rule.nonterminal
Non-terminal this rule reduces to.
array(string|int) LR.rule.symbols
The actual rule
function|string LR.rule.action
Action to do when reducing this rule. function - call this function. string - call this function by name in the object given to the parser. The function is called with arguments corresponding to the values of the elements of the rule. The return value of the function will be the value of this non-terminal. The default rule is to return the first argument.
int LR.rule.has_tokens
This rule contains tokens
int LR.rule.num_nonnullables
This rule has this many non-nullable symbols at the moment.
int LR.rule.number
Sequence number of this rule (used for conflict resolving) Also used to identify the rule.
object LR.rule.pri
Priority and associativity of this rule.
void LR.rule(int nt, array(string|int) r, function|string|void a)
Create a BNF rule.
The rule
rule : nonterminal ":" symbols ";" { add_rule };
might be created as
rule(4, ({ 9, ";", 5, ";" }), "add_rule");
where 4 corresponds to the nonterminal "rule", 9 to "nonterminal" and 5 to "symbols", and the function "add_rule" is too be called when this rule is reduced.
Non-terminal to reduce to.
Symbol sequence that reduces to nt.
Action to do when reducing according to this rule. function - Call this function. string - Call this function by name in the object given to the parser. The function is called with arguments corresponding to the values of the elements of the rule. The return value of the function will become the value of this non-terminal. The default rule is to return the first argument.
| CLASS LR.priority |
Specifies the priority and associativity of a rule.
int LR.priority.value
Priority value
int LR.priority.assoc
Associativity
|
void LR.priority(int p, int a)
Create a new priority object.
Priority.
Associativity.
| CLASS LR.item |
An LR(0) item, a partially parsed rule.
rule LR.item.r
The rule
int LR.item.offset
How long into the rule the parsing has come.
object LR.item.next_state
The state we will get if we shift according to this rule
object LR.item.master_item
Item representing this one (used for shifts).
multiset(string) LR.item.direct_lookahead
Look-ahead set for this item.
multiset(string) LR.item.error_lookahead
Look-ahead set used for detecting conflicts
multiset(object) LR.item.relation
Relation to other items (used when compiling).
int LR.item.counter
Depth counter (used when compiling).
int LR.item.number
Item identification number (used when compiling).
int LR.item.item_id
Used to identify the item. Equal to r->number + offset.
| Module LR.Grammar_parser |
This module generates an LR parser from a grammar specified according to the following grammar:
directives : directive ;
directives : directives directive ;
directive : declaration ;
directive : rule ;
declaration : "%token" terminals ";" ;
rule : nonterminal ":" symbols ";" ;
rule : nonterminal ":" symbols action ";" ;
symbols : symbol ;
symbols : symbols symbol ;
terminals : terminal ;
terminals : terminals terminal ;
symbol : nonterminal ;
symbol : "string" ;
action : "{" "identifier" "}" ;
nonterminal : "identifier" ;
terminal : "string";
int LR.Grammar_parser.error
Error code from the parsing.
parser make_parser(string str, object|void m)
Compiles the parser-specification given in the first argument. Named actions are taken from the object if available, otherwise left as is.
Returns error-code in both Grammar_parser.error and return_value->error.
int|parser make_parser_from_file(string fname, object|void m)
Compiles the file specified in the first argument into an LR parser.
make_parser
| Module String |
string count(string haystack, string needle)
This function counts the number of times the needle can be found in haystack .
Intersections between needles are not counted, ie count("....","..") is 2.
int width(string s)
Returns the width in bits (8, 16 or 32) of the widest character in s .
string implode_nicely(array(string|int|float) foo, string|void separator)
This function implodes a list of words to a readable string. If the separator is omitted, the default is <tt>"and"</tt>. If the words are numbers they are converted to strings first.
`*()
string capitalize(string str)
Convert the first character in str to upper case, and return the new string.
lower_case() , upper_case()
string sillycaps(string str)
Convert the first character in each word (separated by spaces) in str to upper case, and return the new string.
string strmult(string str, int num)
This function multiplies str by num . The return value is the same as appending str to an empty string num times.
This function is obsolete, since this functionality has been incorporated into `*() .
`*()
string common_prefix(array(string) strs)
Find the longest common prefix from an array of strings.
int fuzzymatch(string a, string b)
This function compares two strings using a fuzzy matching routine. The higher the resulting value, the better the strings match.
Array.diff() , Array.diff_compare_table() Array.diff_longest_sequence()
string trim_whites(string s)
Trim leading and trailing spaces and tabs from the string s .
string trim_all_whites(string s)
Trim leading and trailing white spaces characters (" \t\r\n") from the string s .
| CLASS String.String_buffer |
A helper class to optimize iterative string build-up for speed. Can help up performance noticably when dealing with buildup of huge strings by reducing the time needed for rehashing the string every time it grows.
string get_buffer()
Get the contents of the buffer.
void append(string s)
Append the string s to the buffer.
mixed cast(string to)
void flush()
Clear the buffer.
| Namespace :: |
Symbols implicitly inherited from the virtual base class.
These symbols exist mainly to simplify implementation of the corresponding lfuns.
lfun::
mixed `->(string index)
Builtin arrow operator.
This function indexes the current object with the string index . This is useful when the arrow operator has been overloaded.
::`->=()
void `->=(string index, mixed value)
Builtin arrow set operator.
This function indexes the current object with the string index , and sets it to value . This is useful when the arrow set operator has been overloaded.
::`->()
mixed _indices()
Builtin function to list the identifiers of an object. This is useful when lfun::_indices has been overloaded.
::_values, ::`->
mixed _values()
Builtin function to list the values of the identifiers of an object. This is useful when lfun::_values has been overloaded.
::_indices, ::`->
| Namespace lfun:: |
Callback functions used to overload various builtin functions.
The functions can be grouped into a few sets:
Object initialization and destruction.
__INIT() , create() , destroy()
Unary operator overloading.
`~() , `!() , _values() , cast() , _sizeof() , _indices() , __hash()
Binary asymmetric operator overloading.
`+() , ``+() , `-() , ``-() , `&() , ``&() , `|() , ``|() , `^() , ``^() , `<<() , ``<<() , `>>() , ``>>() , `*() , ``*() , `/() , ``/() , `%() , ``%()
Binary symmetric operator overloading.
The optimizer will make assumptions about the relations between these functions.
`==() , _equal() , `<() , `>()
Other binary operator overloading.
`[]() , `[]=() , `->() , `->=() , `+=() , `()()
Overloading of other builtin functions.
_is_type() , _sprintf() , _m_delete() , _get_iterator() , _search()
Although these functions are called from outside the object they
exist in, they will still be used even if they are declared
protected. It is in fact recommended to declare them
protected, since that will hinder them being used for
other purposes.
::
mixed _sqrt()
Called by sqrt when the square root of an object is requested.
_sqrt is not a real lfun, so it must not be defined as static.
predef::sqrt()
mixed _random()
Called by random . Typical uses is when the object implements a ADT, then a call to this lfun should return a random member of the ADT or range implied by the ADT.
predef::random()
void __INIT()
Inherit and variable initialization.
This function is generated automatically by the compiler. It's called just before lfun::create() when an object is instantiated.
It first calls any __INIT functions in inherited classes
(regardless of modifiers on the inherits). It then executes all
the variable initialization expressions in this class, in the
order they occur.
This function can not be overloaded or blocked from executing.
lfun::create()
void lfun:(zero ... args)
Object creation callback.
This function is called right after lfun::__INIT() .
args are the arguments passed when the program was called.
In Pike 7.2 and later this function can be created implicitly by the compiler using the new syntax:
class Foo(int foo) {
int bar;
}
In the above case an implicit lfun::create() is created, and it's equvivalent to:
class Foo {
int foo;
int bar;
protected void create(int foo)
{
local::foo = foo;
}
}
lfun::__INIT() , lfun::destroy()
void destroy(void|int reason)
Object destruction callback.
This function is called right before the object is destructed. That can happen either through a call to predef::destruct() , when there are no more references to the object, or when the garbage collector discovers that it's part of a cyclic data structure that has become garbage.
A flag that tells why the object is destructed:
|
Objects are normally not destructed when a process exits, so
destroy functions aren't called then. Use atexit to get
called when the process exits.
Regarding destruction order during garbage collection:
If an object is destructed by the garbage collector, it's part of
a reference cycle with other things but with no external
references. If there are other objects with destroy
functions in the same cycle, it becomes a problem which to call
first.
E.g. if this object has a variable with another object which (directly or indirectly) points back to this one, you might find that the other object already has been destructed and the variable thus contains zero.
The garbage collector tries to minimize such problems by defining an order as far as possible:
If an object A contains an lfun::destroy and an object B does not, then A is destructed before B.
If A references B single way, then A is destructed before B.
If A and B are in a cycle, and there is a reference somewhere from B to A that is weaker than any reference from A to B, then A is destructed before B.
If a cycle is resolved according to the rule above by ignoring a weaker reference, and there is another ambiguous cycle that would get resolved by ignoring the same reference, then the latter cycle will be resolved by ignoring that reference.
Weak references (e.g. set with predef::set_weak_flag() ) are considered weaker than normal references, and both are considered weaker than strong references.
Strong references are those from objects to the objects of their lexically surrounding classes. There can never be a cycle consisting only of strong references. (This means the gc never destructs a parent object before all children have been destructed.)
An example with well defined destruct order due to strong references:
class Super {
class Sub {
protected void destroy() {
if (!Super::this)
error ("My parent has been destructed!\n");
}
}
Sub sub = Sub();
protected void destroy() {
if (!sub)
werror ("sub already destructed.\n");
}
}
The garbage collector ensures that these objects are destructed in
an order so that werror in Super is called and not
error in Sub.
When the garbage collector calls lfun::destroy , all accessible
non-objects and objects without destroy functions are
still intact. They are not freed if the destroy function
adds external references to them. However, all objects with
lfun::destroy in the cycle are already scheduled for
destruction and will therefore be destroyed even if external
references are added to them.
The garbage collector had completely random destruct order in versions prior to 7.2.
lfun::create() , predef::destruct()
mixed `+(zero arg, zero ... rest)
Left side addition/concatenation callback.
This is used by predef::`+ . It's called with any arguments that follow this object in the argument list of the call to predef::`+ . The returned value should be a new instance that represents the addition/concatenation between this object and the arguments in the order they are given.
It's assumed that this function is side-effect free.
lfun::``+() , lfun::`+=() , predef::`+()
this_program `+=(zero arg, zero ... rest)
Destructive addition/concatenation callback.
This is used by predef::`+ . It's called with any arguments that follow this object in the argument list of the call to predef::`+ . It should update this object to represent the addition/concatenation between it and the arguments in the order they are given. It should always return this object.
This function should only be implemented if lfun::`+() also is. It should only work as a more optimized alternative to that one, for the case when it's safe to change the object destructively and use it directly as the result.
This function is not an lfun for the += operator. It's
only whether or not it's safe to do a destructive change that
decides if this function or lfun::`+() is called; both the
+ operator and the += operator can call either
one.
lfun::`+() , predef::`+()
mixed ``+(zero arg, zero ... rest)
Right side addition/concatenation callback.
This is used by predef::`+ . It's called with any arguments that precede this object in the argument list of the call to predef::`+ . The returned value should be a new instance that represents the addition/concatenation between the arguments in the order they are given and this object.
It's assumed that this function is side-effect free.
lfun::`+() , predef::`+()
mixed `-(void|zero arg)
Negation and left side subtraction/set difference callback.
This is used by predef::`- . When called without an argument the result should be a new instance that represents the negation of this object, otherwise the result should be a new instance that represents the difference between this object and arg .
It's assumed that this function is side-effect free.
lfun::``-() , predef::`-()
mixed ``-(zero arg)
Right side subtraction/set difference callback.
This is used by predef::`- . The result should be a new instance that represents the difference between arg and this object.
It's assumed that this function is side-effect free.
lfun::`-() , predef::`-()
mixed `&(zero ... args)
Left side bitwise and/intersection callback.
It's assumed that this function is side-effect free.
lfun::``&() , predef::`&()
mixed ``&(zero ... args)
Right side bitwise and/intersection callback.
It's assumed that this function is side-effect free.
lfun::`&() , predef::`&()
mixed `|(zero ... args)
Left side bitwise or/union callback.
It's assumed that this function is side-effect free.
lfun::``|() , predef::`|()
mixed ``|(zero ... args)
Right side bitwise or/union callback.
It's assumed that this function is side-effect free.
lfun::`|() , predef::`|()
mixed `^(zero ... args)
Left side exclusive or callback.
It's assumed that this function is side-effect free.
lfun::``^() , predef::`^()
mixed ``^(zero ... args)
Right side exclusive or callback.
It's assumed that this function is side-effect free.
lfun::`^() , predef::`^()
mixed `<<(zero arg)
Left side left shift callback.
It's assumed that this function is side-effect free.
lfun::``<<() , predef::`<<()
mixed ``<<(zero arg)
Right side left shift callback.
It's assumed that this function is side-effect free.
lfun::`<<() , predef::`<<()
mixed `>>(zero arg)
Left side right shift callback.
It's assumed that this function is side-effect free.
lfun::``>>() , predef::`>>()
mixed ``>>(zero arg)
Right side right shift callback.
It's assumed that this function is side-effect free.
lfun::`>>() , predef::`>>()
mixed `*(zero ... args)
Left side multiplication/repetition/implosion callback.
It's assumed that this function is side-effect free.
lfun::``*() , predef::`*()
mixed ``*(zero ... args)
Right side multiplication/repetition/implosion callback.
It's assumed that this function is side-effect free.
lfun::`*() , predef::`*()
mixed `/(zero ... args)
Left side division/split callback.
It's assumed that this function is side-effect free.
lfun::``/() , predef::`/()
mixed ``/(zero ... args)
Right side division/split callback.
It's assumed that this function is side-effect free.
lfun::`/() , predef::`/()
mixed `%(zero ... args)
Left side modulo callback.
It's assumed that this function is side-effect free.
lfun::``%() , predef::`%()
mixed ``%(zero ... args)
Right side modulo callback.
It's assumed that this function is side-effect free.
lfun::`%() , predef::`%()
int `!()
Logical not callback.
Returns non-zero if the object should be evaluated as false,
and 0 (zero) otherwise.
It's assumed that this function is side-effect free.
predef::`!()
mixed `~()
Complement/inversion callback.
It's assumed that this function is side-effect free.
predef::`~()
int(0..1) `==(mixed arg)
Equality test callback.
If this is implemented it might be necessary to implement lfun::__hash too. Otherwise mappings might hold several objects as indices which are duplicates according to this function. Various other functions that use hashing also might not work correctly, e.g. predef::Array.uniq .
It's assumed that this function is side-effect free.
predef::`==() , lfun::__hash
int(0..1) `<(mixed arg)
Less than test callback.
It's assumed that this function is side-effect free.
predef::`<()
int(0..1) `>(mixed arg)
Greater than test callback.
It's assumed that this function is side-effect free.
predef::`>()
int __hash()
Hashing callback.
This function gets called by various mapping operations when the object is used as index in a mapping. It should return an integer that corresponds to the object in such a way that all values which lfun::`== considers equal to the object gets the same hash value.
The function predef::hash does not return hash values that are compatible with this one.
It's assumed that this function is side-effect free.
lfun::`==
mixed cast(string requested_type)
Value cast callback.
Type to cast to.
Expected to return the object value-casted (converted) to the type described by requested_type .
The argument is currently a string with the name of the type, but might in the future be a value of the type type.
Currently casting between object types is a noop.
If the returned value is not deemed to be of the requested type a runtime error may be thrown.
It's assumed that this function is side-effect free.
mixed `[..](zero low, int low_bound_type, zero high, int high_bound_type)
Subrange callback.
It's assumed that this function is side-effect free.
predef::`[..]
mixed `[](zero arg1, zero|void arg2)
Indexing callback.
For compatibility, this is also called to do subranges unless there is a `[..] in the class. See predef::`[..] for details.
It's assumed that this function is side-effect free.
predef::`[]() , predef::`[..]
mixed `[]=(zero arg1, zero arg2)
Index assignment callback.
predef::`[]=() , lfun::`->=()
mixed `->(string arg)
Arrow index callback.
It's assumed that this function is side-effect free.
predef::`->()
mixed `->=(string arg1, zero arg2)
Arrow index assignment callback.
predef::`->=() , lfun::`[]=()
int _sizeof()
Size query callback.
Called by predef::sizeof() to determine the number of elements in an object. If this function is not present, the number of public symbols in the object will be returned.
Expected to return the number of valid indices in the object.
It's assumed that this function is side-effect free.
predef::sizeof()
array _indices()
List indices callback.
Expected to return an array with the valid indices in the object.
It's assumed that this function is side-effect free.
predef::indices() , lfun::_values()
array _values()
List values callback.
Expected to return an array with the values corresponding to the indices returned by lfun::_indices() .
It's assumed that this function is side-effect free.
predef::values() , lfun::_indices()
mixed `()(zero ... args)
Apply callback.
predef::`()
int(0..1) _is_type(string basic_type)
Type comparison callback.
Called by the cast operator to determine if an object simulates a basic type.
One of:
|
The following five shouldn't occurr, but are here for completeness:
|
Expected to return 1 if the object is to be regarded as a
simulation of the type specified by basic_type .
The argument is currently a string with the name of the type, but might in the future be a value of the type type.
It's assumed that this function is side-effect free.
string _sprintf(int conversion_type, mapping(string:int)|void params)
Sprintf callback.
This method is called by predef::sprintf() to print objects. If it is
not present, printing of the object will not be supported for any
conversion-type except for the %O-conversion-type, which
will output "object".
One of:
|
Conversion parameters. The following parameters may be supplied:
|
Is expected to return a string describing the object formatted according to conversion_type .
_sprintf() is currently not called for the following conversion-types:
|
This function might be called at odd times, e.g. before
lfun::create has been called or when an error has occurred.
The reason is typically that it gets called when a backtrace is
being formatted to report an error. It should therefore be very
robust and not make any assumptions about its own internal
state, at least not when conversion_type is 'O'.
It's assumed that this function is side-effect free.
predef::sprintf()
int _equal(mixed arg)
Recursive equality callback.
It's assumed that this function is side-effect free.
predef::equal() , lfun::`==()
mixed _m_delete(mixed arg)
Delete index callback.
predef::m_delete()
predef::Iterator _get_iterator()
Iterator creation callback.
The returned predef::Iterator instance works as a cursor that references a specific item contained (in some arbitrary sense) in this one.
It's assumed that this function is side-effect free.
predef::Iterator , predef::get_iterator , predef::foreach()
mixed _search(mixed needle, mixed|void start)
Search callback.
predef::search()
mixed lfun::`mixed `->symbol()
Variable retrieval callback (aka "getter").
Note that the symbol in the name can be any symbol.
This is not a true LFUN, since it is even more low level!
This function WILL be called even by inheriting programs
when they attempt to access the variable named symbol.
lfun::`->symbol=() , lfun::`->()
void lfun::`void `->symbol=(zero value)
Variable assignment callback (aka "setter").
Note that the symbol in the name can be any symbol.
This is not a true LFUN, since it is even more low level!
This function WILL be called even by inheriting programs
when they attempt to set the variable named symbol.
lfun::`->symbol() , lfun::`->=()
| Namespace cpp:: |
constant __VERSION__
This define contains the current Pike version as a float. If another Pike version is emulated, this define is updated accordingly.
__REAL_VERSION__
constant __REAL_VERSION__
This define always contains the version of the current Pike, represented as a float.
__VERSION__
constant __MAJOR__
This define contains the major part of the current Pike version, represented as an integer. If another Pike version is emulated, this define is updated accordingly.
__REAL_MAJOR__
constant __REAL_MAJOR__
This define always contains the major part of the version of the current Pike, represented as an integer.
__MAJOR__
constant __MINOR__
This define contains the minor part of the current Pike version, represented as an integer. If another Pike version is emulated, this define is updated accordingly.
__REAL_MINOR__
constant __REAL_MINOR__
This define always contains the minor part of the version of the current Pike, represented as an integer.
__MINOR__
constant __BUILD__
This constant contains the build number of the current Pike version, represented as an integer. If another Pike version is emulated, this constant remains unaltered.
__REAL_MINOR__
constant __REAL_BUILD__
This define always contains the minor part of the version of the current Pike, represented as an integer.
__BUILD__
constant __LINE__
This define contains the current line number, represented as an integer, in the source file.
constant __FILE__
This define contains the file path and name of the source file.
constant __DIR__
This define contains the directory path of the source file.
constant __DATE__
This define contains the current date at the time of compilation, e.g. "Jul 28 2001".
constant __TIME__
This define contains the current time at the time of compilation, e.g. "12:20:51".
constant __PIKE__
This define is always true.
constant __AUTO_BIGNUM__
This define is defined when automatic bignum conversion is enabled. When enabled all integers will automatically be converted to bignums when they get bigger than what can be represented by an integer, hampering performance slightly instead of crashing the program.
constant __NT__
This define is defined when the Pike is running on a Microsoft Windows OS, not just Microsoft Windows NT, as the name implies.
constant __amigaos__
This define is defined when the Pike is running on Amiga OS.